API
The Symfony Boilerplate uses GraphQLite to quickly build a GraphQL API based on your models and use cases.
As the documentation of this PHP library covers a lot of aspects, consider reading it to have a better understanding of its functionalities.
#
QueriesA GraphQL query is like a REST GET
request.
Thanks to the @Query
annotation, you may transform any method in the App\UseCase
namespace into a valid GraphQL
endpoint.
Of course, this is a simple example. More complex examples are available in the source code of the application and in the next chapters.
#
MutationsA GraphQL mutation is like a REST POST
request.
Thanks to the @Mutation
annotation, you may transform any method in the App\UseCase
namespace into a valid GraphQL
endpoint.
Of course, this is a simple example. More complex examples are available in the source code of the application and in the next chapters.
#
ModelsThanks to @Type
and @SourceField
annotations, you may convert any PHP class in the App\Domain\Model
namespace to
a valid GraphQL type:
The @SourceField
annotation will look for methods named {name}()
, is{Name}()
and get{Name}()
across the current
class or the parents classes.
note
📣 Identifiers should have the outputType="ID"
parameter.
To allow GraphQLite to automatically inject an instance of
User
in a query or mutation, i.e:
You have to create a GraphQLite factory in the DAO:
In your GraphQL client, you may now call this mutation by using the id
parameter of the factory:
#
EnumsClasses from the namespace App\Domain\Enum
which extends MyCLabs\Enum\Enum
are automatically converted to valid
GraphQL types.
For instance: