getpop / graphql-server
GraphQL server in PHP, implemented through the PoP API
Requires
- php: ~7.2
- graphql-by-pop/graphql-request: dev-master
Requires (Dev)
- getpop/access-control: dev-master
- phpstan/phpstan: ^0.12
- phpunit/phpunit: >=8.5
- squizlabs/php_codesniffer: ^3.0
Suggests
- getpop/access-control: Integrates well with Access Control
This package is auto-updated.
Last update: 2020-08-08 04:40:18 UTC
README
GraphQL server in PHP, implemented through the PoP API
Install
Installing the GraphQL server
Follow the instructions in the GraphQL by PoP installation page.
Installing the library in a PoP application
Via Composer
composer require graphql-by-pop/graphql-server
To enable pretty API endpoint /api/graphql/
, follow the instructions here
Usage
Initialize the component:
\PoP\Root\ComponentLoader::initializeComponents([ \PoP\GraphQLServer\Component::class, ]);
100% compliant of GraphQL syntax
All GraphQL queries are supported (click on the links below to try them out in GraphiQL):
- Fields
- Field arguments
- Aliases
- Fragments
- Operation name
- Variables
- Variables inside fragments
- Default variables
- Directives
- Fragments with directives
- Inline fragments
GraphQL by PoP supports query batching. This query contains all queries from above:
Extended GraphQL
An upgraded implementation of the GraphQL server, which enables to resolve queries as a scripting language, is found under this repo.
It supports several features not currently defined by the GraphQL spec, including composable fields and composable directives.
Support for REST
By installing the REST package, the GraphQL server can also satisfy REST endpoints, from a single source of truth. Check out these example links:
Demo
The GraphQL API (running on top of a WordPress site) is deployed under this endpoint: https://newapi.getpop.org/api/graphql/
You can play with it through the following clients:
- GraphiQL: https://newapi.getpop.org/graphiql/
- GraphQL Voyager: https://newapi.getpop.org/graphql-interactive/
Standards
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
composer test
Static Analysis
Execute phpstan with level 5:
composer analyse
To run checks for level 0 (or any level from 0 to 8):
./vendor/bin/phpstan analyse -l 0 src tests
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email leo@getpop.org instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.