type Query {
category(id: String!): Category
}
type Category {
id: ID!
title: String!
active: Bool!
articles: [Article]
parent: Category
siblings: [Category]
children: [Category]
}
type Article {
id: ID!
title: String!
category: Category
}
{
query {
category(id: "943a9ba3050e78b443c16e043ae60ef3") {
id
title
children {
id
title
}
}
}
}
{
"data": {
"category": {
"id": "943a9ba3050e78b443c16e043ae60ef3",
"title": "Kiteboarding",
"children": [
{
"id": "0f41a4463b227c437f6e6bf57b1697c4",
"title": "Trapeze"
},
{
"id": "0f4f08358666c54b4fde3d83d2b7ef04",
"title": "Kiteboards"
}
]
}
}
}
Create a complete GraphQL API by simply annotating your PHP classes
— GraphQLite docs
class CategoryController
{
/**
* @Query()
*/
public function category(string $id): Category
{
// Some code that looks for a category and returns it.
}
}
/**
* @Type()
*/
class Category
{
/**
* @Field()
*/
public function getTitle(): string
{
return $this->title;
}
// ...
}
type Query {
category(id: String!): Category
}
type Category {
title: String!
}
graphql_namespace_mapper
in services.yaml
graphql_permission_provider
in services.yaml
composer create-project oxid-esales/graphql-module-skeleton