Skip to content

Commit b79d090

Browse files
authored
minor #927 Adding GitHub authentication to GraphQL documentation (legionth)
This PR was merged into the 2.x branch. Discussion ---------- First of all: I love your library, great work 👍 While discovering the official [GitHub GraphQL documentation](https://docs.github.com/en/free-pro-team@latest/graphql) and your repository, I recognized that is currently not possible to communicate with the GraphQL API without authenticating your requests. I updated the documentation on behalf of GraphQL and added the `\Github\Client::authenticate` to the code examples. I also added small chapter with some links. This may help other developers to get started with the GraphQL library 😄 Commits ------- 21feb10 Adding GitHub authentication to GraphQL documentation
2 parents bb32763 + 21feb10 commit b79d090

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

doc/graphql.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ Wraps [GitHub v4 API (GraphQL API)](http://developer.github.com/v4/).
99
$rateLimits = $client->api('graphql')->execute($query);
1010
```
1111

12+
#### Authentication
13+
14+
To use [GitHub v4 API (GraphQL API)](http://developer.github.com/v4/) requests must [authenticated]((../security.md)).
15+
16+
```php
17+
$client->authenticate($token, null, Github\Client::AUTH_ACCESS_TOKEN);
18+
19+
$result = $client->api('graphql')->execute($query);
20+
```
21+
1222
#### Use variables
1323

1424
[Variables](https://developer.github.com/v4/guides/forming-calls/#working-with-variables) allow specifying of requested data without dynamical change of a query on a client side.
@@ -28,5 +38,7 @@ $variables = [
2838
'organizationLogin' => 'KnpLabs'
2939
];
3040

41+
$client->authenticate('<your-token>', null, Github\Client::AUTH_ACCESS_TOKEN);
42+
3143
$orgInfo = $client->api('graphql')->execute($query, $variables);
32-
```
44+
```

0 commit comments

Comments
 (0)