PHP code example of garlic / graphql-wrapper
1. Go to this page and download the library: Download garlic/graphql-wrapper library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
garlic / graphql-wrapper example snippets
$graphQLService = $this->get(GraphQLService::class);
$addressQuery = $graphQLService->createQuery('serviceName.QueryName');
$addressQuery
->select('id', 'city', 'zipcode')
->where('country = Ukraine');
$result = $graphQLService->fetch();
$graphQLService = $this->get(GraphQLService::class);
$apartmentQuery = $graphQLService->createQuery('serviceName.QueryName');
$apartmentQuery
->select('id', 'buildYear', 'address.id', 'address.city', 'address.country')
->where('size = 5');
$result = $graphQLService->fetch();
$graphQLService = $this->get(GraphQLService::class);
$apartmentQuery = $graphQLService->createQuery('serviceName.QueryName');
$apartmentQuery
->select('id', 'buildYear', 'address.id', 'address.city', 'address.country')
->where('size = 5', 'address.country = Ukraine');
$result = $graphQLService->fetch();
$graphQLService = $this->get(GraphQLService::class);
$addressQuery = $graphQLService->createQuery('firstServiceName.QueryName');
$addressQuery
->select('id', 'city', 'country')
->where('country = Ukraine')
;
$apartmentQuery = $graphQLService->createQuery('secondServiceName.QueryName');
$apartmentQuery
->select('id', 'size', 'addressId')
->where('size = 5')
->stitchOne($addressQuery, 'address', 'addressId', 'id')
;
$result = $graphQLService->fetch();
$graphQLService = $this->get(GraphQLService::class);
$addressQuery = $graphQLService->createQuery('firstServiceName.QueryName');
$addressQuery
->select('id', 'city', 'country')
->where('country = Ukraine')
;
$apartmentQuery = $graphQLService->createQuery('secondServiceName.QueryName');
$apartmentQuery
->select('id', 'size', 'addressId')
->where('size = 5')
->stitchMany($addressQuery, 'address', 'addressId', 'id')
;
$result = $graphQLService->fetch();
$graphQLService = $this->get(GraphQLService::class);
$addressQuery = $graphQLService->createQuery('firstServiceName.QueryName');
$addressQuery
->select('id', 'city', 'country')
->where('country = Ukraine')
;
$apartmentQuery = $graphQLService->createQuery('secondServiceName.QueryName');
$apartmentQuery
->select('id', 'size', 'address.id', 'address.city', 'address.country')
->where('size = 5')
->stitchOne($addressQuery, 'fullAddress', 'address.id', 'id')
;
$result = $graphQLService->fetch();
$graphQLService = $this->get(GraphQLService::class);
$apartmentQuery = $graphQLService->createQuery('secondServiceName.QueryName');
$apartmentQuery
->select(...)
->where(...)
->addHeader('Authorization', 'abc');
$graphQLService = $this->get(GraphQLService::class);
$apartmentMutation = $graphQLService->createNewMutation('ServiceName.CreateMutationName');
$apartmentMutation
->set('size = 3', 'buildYear = 2018')
->select('id');
$result = $graphQLService->fetch();
$graphQLService = $this->get(GraphQLService::class);
$apartmentMutation = $graphQLService->createUpdateMutation('ServiceName.UpdateMutationName');
$apartmentMutation
->set('size = 3', 'buildYear = 2018')
->where('size = 5')
->select('id');
$result = $graphQLService->fetch();
$graphQLService = $this->get(GraphQLService::class);
$apartmentMutation = $graphQLService->createDeleteMutation('ServiceName.DeleteMutationName');
$apartmentMutation
->where('size = 5')
->select('id');
$result = $graphQLService->fetch();
$graphQLService = $this->get(GraphQLService::class);
$addressMutation = $graphQLService->createNewMutation('template.AddressCreate');
$addressMutation
->select('id', 'country', 'city')
->set('country = Ukraine', 'city = Boyarka', 'street = Kyivska', 'zipcode = 20214', 'house = 1');
$apartmentQuery = $graphQLService->createQuery('template.AddressFind');
$apartmentQuery
->select('id')
->where(['id' => 123])
;
$result = $graphQLService->fetchAsync();
$graphQLService = $this->get(GraphQLService::class);
$addressMutation = $graphQLService->createNewMutation('FirstServiceName.CreateMutationName');
$addressMutation
->set('city = Kyiv', 'country = Ukraine')
->select('id');
$apartmentQuery = $graphQLService->createQuery('SecondServiceName.QueryName');
$apartmentQuery
->select('id', 'size', 'address.id', 'address.city', 'address.country')
->where('size = 5')
->stitchOne($addressMutation, 'newAddress', 'address.country', 'country')
;
$result = $graphQLService->fetch();