astrotomic / graphql-query-builder
Fund package maintenance!
Gummibeer
SarahSibert
Issuehunt
forest.astrotomic.info
Requires
- php: ^7.4 || ^8.0
Requires (Dev)
- pestphp/pest: ^v1.15.0
- spatie/pest-plugin-snapshots: ^1.1
README
This package is an opinionated GraphQL Query Builder not fully compatible with all GraphQL specs (yet). In case you miss a feature you can open an issue so we can discuss a solution.
Installation
composer require astrotomic/graphql-query-builder
Usage
use Astrotomic\GraphqlQueryBuilder\Graph; use Astrotomic\GraphqlQueryBuilder\Query; Graph::query( Query::from('user') ->with(['login' => 'Gummibeer']) ->select( Query::from('sponsorshipsAsMaintainer') ->with(['first' => 100, 'after' => 'ABC']) ->select( Query::from('pageInfo')->select('hasNextPage', 'endCursor'), Query::from('nodes')->select( Query::from('sponsorEntity')->select( '__typename', Query::for('User')->select('login', 'avatarUrl', 'databaseId', 'name'), Query::for('Organization')->select('login', 'avatarUrl', 'databaseId', 'name'), ) ) ) ) )
query { user(login: "Gummibeer") { sponsorshipsAsMaintainer(first: 100, after: "ABC") { pageInfo { hasNextPage endCursor } nodes { sponsorEntity { __typename ... on User { login avatarUrl databaseId name } ... on Organization { login avatarUrl databaseId name } } } } } }