wappcode / graphql-basic-client
There is no license information available for the latest version (1.0.2) of this package.
1.0.2
2024-06-18 22:09 UTC
Requires (Dev)
- phpunit/phpunit: ^9
This package is not auto-updated.
Last update: 2025-02-26 01:40:50 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);