forked from spawnia/sailor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sailor.php
56 lines (50 loc) · 1.71 KB
/
sailor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php declare(strict_types=1);
use Spawnia\Sailor\EndpointConfig;
/*
* This must return a map from endpoint names to EndpointConfig classes.
*/
return [
'example' => new class() extends EndpointConfig {
/**
* Instantiate a client for Sailor to use for querying.
*
* You may use one of the built-in clients, such as Guzzle, or
* bring your own implementation.
*
* Configuring the client is up to you. Since this configuration
* file is just PHP code, you can do anything. For example, you
* can use environment variables to enable a dynamic config.
*/
public function makeClient(): Spawnia\Sailor\Client
{
return new Spawnia\Sailor\Client\Guzzle(
'https://example.com/graphql',
[
'headers' => [
'Authorization' => 'Bearer foobarbaz',
],
]
);
}
/** The namespace the generated classes will be created in. */
public function namespace(): string
{
return 'Vendor\\ExampleApi';
}
/** Path to the directory where the generated classes will be put. */
public function targetPath(): string
{
return __DIR__ . '/generated/ExampleApi';
}
/** Where to look for .graphql files containing operations. */
public function searchPath(): string
{
return __DIR__ . '/src';
}
/** The location of the schema file that describes the endpoint. */
public function schemaPath(): string
{
return __DIR__ . '/example.graphql';
}
},
];