folkloreinc / laravel-graphql

Facebook GraphQL for Laravel 5. It supports Relay, eloquent models, validation and GraphiQL.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create contracts Type to use in all Graph type

FabrizioCafolla opened this issue · comments

I thought that to add types (Timestamp, PaginationMeta, Links etc ..) in a simple and intuitive way was to create a class that has a static method for each type and that calls it by passing the value of the query in the "resolve" so that can be processed independently. This allows me to call these methods staunchly and makes it easy to use them in multiple types.
What do you think?

UserType.php with TimestampType for data
query=query+FetchUsers{users{id,name,timestamp{created_at,updated_at}}}
usertype

TypeRegistry all method that return Contracts type with resolve() function
typeregistry

TimestampType is type of time, you can add field to fields array
timestamptype

schermata del 2018-10-30 10-10-00