https://github.com/mathsgod/gql-client
A simple GraphQL client tools
https://github.com/mathsgod/gql-client
graphql php
Last synced: about 2 months ago
JSON representation
A simple GraphQL client tools
- Host: GitHub
- URL: https://github.com/mathsgod/gql-client
- Owner: mathsgod
- License: mit
- Created: 2019-01-09T07:59:29.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-26T02:41:43.000Z (about 2 years ago)
- Last Synced: 2025-09-04T18:53:46.747Z (10 months ago)
- Topics: graphql, php
- Language: PHP
- Homepage:
- Size: 104 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gql-client
## Client example
### Query
```php
$client = new GQL\Client($server_address);
$data = $client->query([
"me" => [
"first_name",
"last_name"
]
]);
```
#### With arguments
```php
$client = new GQL\Client($server_address);
$data = $client->query([
"getUser" => [
"__args"=>[
"id"=>1
],
"first_name",
"last_name",
"findInvoice"=>[
"__args"=>[
"status"=>"pending"
],
"invoice_no"
]
]
]);
```
### Mutation and Subscription
```php
$data = $client->mutation("updateUser",[
"__args"=>["user_id"=>1,"first_name"=>"Raymond"]
]);
$data=$client->subscription("createUser",[
"__args"=>["first_name"=>"raymond"]
]);
```
### auth
```php
$client = new GQL\Client($server_address);
$client->auth=["username","password"];
$data = $client->query([
"me" => [
"first_name",
"last_name"
]
]);
```
### no ssl check
```php
$client = new GQL\Client($server_address,["verify"=>false]);
$data = $client->query([
"me" => [
"first_name",
"last_name"
]
]);
```
## Builder
### Query
```php
echo Builder::Query([
"me" => [
"first_name",
"last_name"
]
]);
// query{ me {first_name last_name} }
```
### Mutation
```php
echo Builder:Mutation("updateUser",[
"__args"=>[
"user_id"=>1,
"first_name"=>"Raymond"
]
]);
// mutation{ updateUser(user_id:1, first_name:"Raymond") }
```
### Subscription
```php
echo Builder:Mutation("createUser",["__args"=>["first_name"=>"Raymond"]]);
// subscription{ createUser(first_name:"Raymond") }
```