Download the PHP package shish/gqla without Composer
On this page you can find all versions of the php package shish/gqla. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package gqla
Short Description A set of annotations for generating graphql APIs
License MIT
Homepage https://github.com/shish/gqla
Informations about the package gqla
gqla
A GraphQL schema generator based on PHP Attributes
Because when your webapp already has objects for internal use, you shoudn't need to rewrite or duplicate everything in order to query those objects via graphql :)
The schemas generated here are based on https://github.com/webonyx/graphql-php, so once you've generated a schema, look at the docs over there for how to make use of it
Example:
Then new \GQLA\Schema();
will search for all annotated objects and
return a graphql schema like:
So you can send a query like
And get a response like
API
These annotations have several common parameters:
name
: Give a specific name to this type / field (default: Use the class / property / function name)-
type
: Give a specific type to the field (default: infer this from the PHP-types-to-GraphQL-types map)- Note that if your PHP type is
array
, then you must specifytype
with something more specific for GraphQL, for example:
- Note that if your PHP type is
-
args
: Override the inferred types for any function arguments- As with type, note that this is required whenever a PHP function accepts an array as input, for example:
extends
: By default, an exposed field on an exposed object will be added as a field of that object. You can also extend your other objects (eg, a "likes" plugin could add anumber_of_likes
field onto yourBlogPost
object)description
: Add a description to your GraphQL schema for anybody who wants to develop client appsdeprecationReason
: Mark this field as deprecated