From 80ceb996ab15c1348b168f9c7792b088de1d1cd9 Mon Sep 17 00:00:00 2001 From: Minh Vuong Date: Wed, 27 Mar 2024 17:27:39 +0700 Subject: [PATCH] docs: add example section --- README.md | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/README.md b/README.md index 4555628..3486582 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,53 @@ then generate PHP code with command: ./vendor/bin/x-graphql-codegen x-graphql:codegen:generate ``` +Example +------- + +Add `x-graphql/http-schema` package for executing schema over http: + +```shell +composer require x-graphql/http-schema +``` + +Init config file: + +```shell +./vendor/bin/x-graphql-codegen x-graphql:codegen:init-config +``` + +Add `example.graphql` to your current working directory with content: + +```graphql +query getCountries { + countries { + name + } +} +``` + +Run command to generate PHP code: + +```shell +./vendor/bin/x-graphql-codegen x-graphql:codegen:generate +``` + +Use generated query class: + +```php +getCountries(); + +var_dump($result->toArray()); +``` + Credits -------