在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):softonic/graphql-client开源软件地址(OpenSource Url):https://github.com/softonic/graphql-client开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):PHP GraphQL ClientPHP Client for GraphQL InstallationVia composer:
DocumentationTo instantiate a client with an OAuth2 provider: <?php
$options = [
'clientId' => 'myclient',
'clientSecret' => 'mysecret',
];
$provider = new Softonic\OAuth2\Client\Provider\Softonic($options);
$config = ['grant_type' => 'client_credentials', 'scope' => 'myscope'];
$cache = new \Symfony\Component\Cache\Adapter\FilesystemAdapter();
$client = \Softonic\GraphQL\ClientBuilder::buildWithOAuth2Provider(
'https://catalog.swarm.pub.softonic.one/graphql',
$provider,
$config,
$cache
);
// Query Example
$query = <<<'QUERY'
query GetFooBar($idFoo: String, $idBar: String) {
foo(id: $idFoo) {
id_foo
bar (id: $idBar) {
id_bar
}
}
}
QUERY;
$variables = ['idFoo' => 'foo', 'idBar' => 'bar'];
$response = $client->query($query, $variables);
// Mutation Example
$mutation = <<<'MUTATION'
mutation ($foo: ObjectInput!){
CreateObjectMutation (object: $foo) {
status
}
}
MUTATION;
$variables = [
'foo' => [
'id_foo' => 'foo',
'bar' => [
'id_bar' => 'bar'
]
]
];
$response = $client->query($mutation, $variables); To instantiate a client without OAuth2: <?php
$client = \Softonic\GraphQL\ClientBuilder::build('https://catalog.swarm.pub.softonic.one/graphql');
$query = <<<'QUERY'
query GetFooBar($idFoo: String, $idBar: String) {
foo(id: $idFoo) {
id_foo
bar (id: $idBar) {
id_bar
}
}
}
QUERY;
$variables = [
'idFoo' => 'foo',
'idBar' => 'bar',
];
$response = $client->query($query, $variables); Testing
To run the tests, run the following command from the project folder. $ docker-compose run test To run interactively using PsySH: $ docker-compose run psysh LicenseThe Apache 2.0 license. Please see LICENSE for more information. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论