PHP code example of phonetworks / pho-lib-graphql-parser
1. Go to this page and download the library: Download phonetworks/pho-lib-graphql-parser 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/ */
phonetworks / pho-lib-graphql-parser example snippets
$parsed = new Pho\Lib\GraphQL\Parser\Parse("BasicSchema.graphql");
foreach($parsed as $entity) {
$entity_name = $entity->name(); // Basic
$implementations = $entity->implementations(); // an array with a single element
$implementation_name = $entity->implementations(0)->name(); // Something
$directives = $entity->directives(); // no root level directive. But we would have one if it was type Basic @is_a { ...
$fields = $entity->fields(); // we have three; id, context and user.
$field_1["name"] = $entity->field(0)->name(); // id
$field_1["type"] = $entity->field(0)->type(); // ID
$field_1["nullable"] = $entity->field(0)->nullable(); // false (due to !)
$field_3["directives"][0] = $entity->field(0)->directive(0)->name(); // the_directive
$field_3["directives"][0]["arguments"][0]["name"] = $entity->field(0)->directive(0)->name(); // the_argument
$field_3["directives"][0]["arguments"][0]["value"] = $entity->field(0)->directive(0)->value(); // TheValue
}