wappcode / graphql-basic-client
Installs: 41
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/wappcode/graphql-basic-client
Requires (Dev)
- phpunit/phpunit: ^9
This package is not auto-updated.
Last update: 2025-10-08 04:54:18 UTC
README
Allows making queries to a graphql API.
Gets an array as result
Requirements
Needs curl extension enabled
Install
composer require wappcode/graphql-basic-client
Use
Query
$client = new GQLClient("http://graphql-api");
$query = '
query {
users {
id
name
firstname
lastname
email
}
}
';
$result = $client->execute($query);
Mutation
$client = new GQLClient("http://graphql-api");
$query = '
mutation MutationCreateUser($input: UserInput) {
user: createUser(input: $input) {
id
name
firstname
lastname
email
}
}
';
$variables = [
"input" => [
"firstname" => "John",
"lastname" => "Doe",
"email" => "johndoe@demo.com"
]
];
$headers = [
"Authorization: Bearer jwt"
];
$result = $client->execute($query, $variables, $headers);