Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/overblog/graphqlphpgenerator
GraphQL PHP types generator...
https://github.com/overblog/graphqlphpgenerator
generator graphql graphql-php php
Last synced: 3 months ago
JSON representation
GraphQL PHP types generator...
- Host: GitHub
- URL: https://github.com/overblog/graphqlphpgenerator
- Owner: overblog
- License: mit
- Created: 2016-04-22T15:07:35.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-03-07T18:19:52.000Z (almost 4 years ago)
- Last Synced: 2024-09-20T08:08:32.394Z (4 months ago)
- Topics: generator, graphql, graphql-php, php
- Language: PHP
- Homepage:
- Size: 97.7 KB
- Stars: 29
- Watchers: 12
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
OverblogGraphQLPhpGenerator
===========================GraphQL PHP types generator...
[![Code Coverage](https://scrutinizer-ci.com/g/overblog/GraphQLPhpGenerator/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/overblog/GraphQLPhpGenerator/?branch=master)
[![Build Status](https://travis-ci.org/overblog/GraphQLPhpGenerator.svg?branch=master)](https://travis-ci.org/overblog/GraphQLPhpGenerator)Installation
------------```bash
composer require overblog/graphql-php-generator
```Usage
-----```php
[
'type' => 'interface',
'config' => [
'description' => new Expression('\'A character\' ~ \' in the Star Wars Trilogy\''),
'fields' => [
'id' => ['type' => 'String!', 'description' => 'The id of the character.'],
'name' => ['type' => 'String', 'description' => 'The name of the character.'],
'friends' => ['type' => '[Character]', 'description' => 'The friends of the character.'],
'appearsIn' => ['type' => '[Episode]', 'description' => 'Which movies they appear in.'],
],
'resolveType' => 'Overblog\\GraphQLGenerator\\Tests\\Resolver::resolveType',
],
],
/*...*/
'Query' => [
'type' => 'object',
'config' => [
'description' => 'A humanoid creature in the Star Wars universe or a faction in the Star Wars saga.',
'fields' => [
'hero' => [
'type' => 'Character',
'args' => [
'episode' => [
'type' => 'Episode',
'description' => 'If omitted, returns the hero of the whole saga. If provided, returns the hero of that particular episode.',
],
],
'resolve' => ['Overblog\\GraphQLGenerator\\Tests\\Resolver', 'getHero'],
],
],
],
/*...*/
],
];$typeGenerator = new TypeGenerator('\\My\\Schema\\NP');
$classesMap = $typeGenerator->generateClasses($configs, __DIR__ . '/cache/types');$loader->addClassMap($classesMap);
$schema = new Schema(\My\Schema\NP\QueryType::getInstance());
```