garlic / graphql
GraphQL Bundle uses for sending and receiving graphql queries among microservices through Garlic Message Bus.
Installs: 2 501
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 8
Forks: 1
Open Issues: 1
Type:symfony-bundle
Requires
- php: >=7.1
- symfony/maker-bundle: ^1.12
- symfony/orm-pack: ^1.0
- symfony/validator: ^4.2
- youshido/graphql-bundle: ^1.4
- dev-master
- 1.4.3
- 1.4.2
- 1.4.1
- 1.3.11
- 1.3.10
- 1.3.9
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.2.2
- 1.2.1
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-feature/object_hydrator
- dev-feature/arg_helper
- dev-feature/fix-validator-version
- dev-generator-usefull-updates
- dev-add_list_type
- dev-feature/argument-filter
- dev-add_validation_add_errors
- dev-feature/unset-fix
- dev-fix_required_with_group
- dev-add_arguments_to_builder
- dev-list_type_issue
- dev-feature/readme-fix
This package is not auto-updated.
Last update: 2024-11-19 09:06:39 UTC
README
This bundle allow to communicate microservices via graphql to each other. It should be installed on both endpoints for proper message encode/decode flow.
This bundle based on youshido-php/GraphQLBundle, so special thanks to this guys for the excellent work! We've just made a couple updates ;)
Configuration
There are necessary things make this bundle works:
Add bundle to the Symfony project
composer require garlic/graphql
Initialize GraphQL schema(create schema, query and mutation fields)
bin/console make:graphql:init
Create graphql type (command able to get fields from existing Entity)
bin/console make:graphql:type
The command suggest you to create full CRUD mutations and queries, just type "y" to do so. There would be created CRUD-classes with related functionality. Last thing you need to make this bundle working is to update your service.yaml
# Make graphql services public App\Service\GraphQL\: resource: '../src/Service/GraphQL/*' public: true
Make your first graphql query or mutation
bin/console make:graphql:query
Now you can review and update newly created files!
It's time to run your first query! Try to send your query to mydomain.com/graphql
Usage
Example steps to use bundle after init
- Create Entity (for example Apartments)
- Create GraphQL type by using command above (for example name it Apartment), type "y" to make CRUD mutations automatically.
- Try to execute a query
{
ApartmentFind(id:1){
id
}
}
Using related types
- Let's create new Entity (for example Address) and connect it to Apartments by using many to one relation.
- Create GraphQL type "Address" similar to step one
- Add newly created type to Apartment type as
new Address()
- Try to find Apartment with address fields (for example id)
{
ApartmentFind(id:1){
id
address {
id
}
}
}
or directly by Address "where" query (for example id)
{
ApartmentFind(address:{id:1}){
id
address {
id
}
}
}
GraphiQL extension
You can write queries in interactive editor with integrated documentation about schemas, queries and mutation. To run this editor just run graphiql extension. Type to access to extension - mydomain.com/graphql/explorer Extension is accessible only in development mode of Symfony application.