Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Graphql Bundle Laravel Package

overblog/graphql-bundle

View on GitHub
Deep Wiki
Context7

GraphQL schema language

This section we show how to define schema types using GraphQL schema language. If you want to learn more about it, you can see the official documentation or this cheat sheet.

Configuration

overblog_graphql:
    definitions:
        schema:
            # ...
        mappings:
            types:
                -
                    type: graphql
                    dir: "%kernel.project_dir%/config/graphql/types"

Usage

Define Types

GraphQL documentation about types and fields.

# config/graphql/types/schema.types.graphql

type Character {
  # Name of the character
  name: String! 
  # This character appears in those episodes
  appearsIn: [Episode]!
}
Define Enumeration types

GraphQL documentation about Enumerations types.

# Enumeration of episodes
enum Episode {
  NEWHOPE [@deprecated](https://github.com/deprecated)
  EMPIRE
  JEDI
}
Define Interfaces

GraphQL documentation about Interfaces.

interface Character {
  id: ID!
  name: String!
  friends: [Character] [@deprecated](https://github.com/deprecated)(reason: "This field was deprecated!")
  appearsIn: [Episode]!
}
type Human implements Character {
  id: ID!
  name: String!
  friends: [Character]
  appearsIn: [Episode]!
  starships: [Starship]
  totalCredits: Int
}

type Droid implements Character {
  id: ID!
  name: String!
  friends: [Character]
  appearsIn: [Episode]!
  primaryFunction: String
}
Define queries

GraphQL documentation about Query type.

type RootQuery {
  # Access all characters
  characters: [Character]!
}

Do not forget to configure your schema query type, as described in the schema documentation.

overblog_graphql:
    definitions:
        schema:
            query: RootQuery
Define mutations

GraphQL documentation about Mutation type.

input CreateCharacter {
  name: String!
}

input UpdateCharacter {
  name: String!
}

type RootMutation {
  createCharacter(character: CreateCharacter!): Character!
  updateCharacter(characterId: ID!, character: UpdateCharacter!): Character!
}

Do not forget to configure your schema mutation type, as described in the schema documentation.

overblog_graphql:
    definitions:
        schema:
            mutation: RootMutation

When using this shorthand syntax, you define your field resolvers (and some more configuration) separately from the schema. Since the schema already describes all of the fields, arguments, and result types, the only thing left is a collection of callable that are called to actually execute these fields. This can be done using resolver-map.

Notes:

  • This feature is experimental and could be improve or change in future releases
  • Only type definition is allowed right now using this shorthand syntax
  • The definition of schema root query or/and mutation should still be done in main configuration file.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle