A simple bearer graphql client using guzzel for laravel or lumen projects.
composer require onefit/graphql-client
The client currently support only the bearer token for authentication
Define the base url in your .env file.
GRAPHQL_URL=https://some-url
//a simple mutation example
$client = app(ApiClient::class);
$response = $client->sendRequest('mutation someOperation(
$instanceId: ID!
$memberId: String!
) {
someOperation (
instanceId: $instanceId,
input: {
memberId: $memberId
}
)
{
member {
id
firstName
lastName
email
gender
}
status
updatedAt
createdAt
}
}', [
'variables' => [
'instanceId' => $eventInstanceId,
'memberId' => (string) $memberId,
],
]);
$responseObj = json_decode($response->getBody()->getContents(), true);