phonetworks / pho-compiler
Compiles GraphQL schema into PHP classes for use in Pho stack.
Fund package maintenance!
Open Collective
Requires
- php: >=5.3.0
- ext-curl: *
- ext-dom: *
- danielstjules/stringy: ^3.0
- kyeates/psr-loggers: ^1.0
- mustache/mustache: ^2.11
- phonetworks/pho-lib-graphql-parser: ^3.0
- psr/log: ^1.0
Requires (Dev)
- fzaninotto/faker: ^1.6
- phpdocumentor/phpdocumentor: *
- phpunit/phpunit: ^5.7
- psy/psysh: *
- roave/security-advisories: dev-master
- squizlabs/php_codesniffer: 3.*
This package is auto-updated.
Last update: 2025-03-01 00:22:24 UTC
README
Pho-Compiler
Compiles GraphQL schema into PHP executables for use throughout Phở stack.
Getting Started
Please note, this repository uses submodules, for unit tests. The recommended way to install pho-compiler is through composer.
git clone https://github.com/phonetworks/pho-compiler git submodule init git submodule update composer install
Schema
Recommendations
A Phở-compatible GraphQL schema (also called a "PhoGQL" file) is advised to end with the following file extension: .pgql
GraphQL
- PhởGQL is built on top of GraphQL. For more information on GraphQL specs, please visit http://facebook.github.io/graphql/.
- A PhoGQL file may include multiple entity definitions. However, it is advised to use (a) a single definition per file or (b) only a single semantically linked group of node and edge definitions per file.
Versioning
- PhởGQL files must start with a version declaration. For version 1, the one and only version supported so far, it is
# pho-graphql-schema-v1
- This declaration must be at the very top of the file and must not be preceded by any other word or character.
- The following regular expression pattern is used to match the version:
/^#( )*pho\-graphql\-v1(\r\n|\r|\n| )+/i
- All future versions and their patterns will be placed in the file Types.php
Types
- A PhởGQL definition must implement one of ActorNode, GraphNode, ObjectNode or ReadEdge, SubscribeEdge, TransmitEdge, WriteEdge entities. For more information on these entities, check out pho-framework.
- While GraphQL allows multiple inheritance, the Phở compiler will evaluate only the first interface declared in each definition.
Directives
- Directives are case-insensitive. Similarly arguments are case-insensitive too.
Tips
- Start by defining the Actor edge
- Outgoing edges are important.
- Make sure all outgoing edges are done.