Skip to content

Commit f1483c0

Browse files
Update website docs with examples
1 parent 04f0d4d commit f1483c0

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

website/docs/transports/graphql.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,85 @@ type Student implements User {
257257
}
258258
```
259259

260+
## Examples
261+
262+
### Authenticate with a Service
263+
264+
```graphql
265+
mutation Authenticate {
266+
authenticate(serviceName: "password", params: { password: "<pw>", user: { email: "<email>" } })
267+
}
268+
```
269+
270+
1. `serviceName` - corresponds to the package you are using to authenticate (e.g. oauth, password, twitter, instagram, two factor, token, etc).
271+
2. `params` - These will be different depending on the service you are using.
272+
273+
- Twitter/Instagram
274+
275+
```graphql
276+
mutation Authenticate {
277+
authenticate(
278+
serviceName: "twitter"
279+
params: { access_token: "<access-token>", access_token_secret: "<access-token-secret>" }
280+
)
281+
}
282+
```
283+
284+
- OAuth
285+
286+
```graphql
287+
mutation Authenticate {
288+
authenticate(serviceName: "oauth", params: { provider: "<your-provider>" })
289+
}
290+
```
291+
292+
- Password: Below the `user` contains `email` but can contain one or more of `id`, `email` or `username` too.
293+
294+
```graphql
295+
mutation Authenticate {
296+
authenticate(serviceName: "password", params: { password: "<pw>", user: { email: "<email>" } })
297+
}
298+
```
299+
300+
- Two Factor
301+
302+
```graphql
303+
mutation Authenticate {
304+
authenticate(serviceName: "two-factor", params: { code: "<two-factor-code>" })
305+
}
306+
```
307+
308+
- Token
309+
310+
```graphql
311+
mutation Authenticate {
312+
authenticate(serviceName: "token", params: { token: "<token>" })
313+
}
314+
```
315+
316+
#### Verify Authentication
317+
318+
The way to check if a user has been successfully authenticated is identical, with the exception that `verifyAuthentication` returns a `boolean` instead of a `LoginResult`:
319+
320+
```graphql
321+
mutation Verify {
322+
verifyAuthentication(
323+
serviceName: "password"
324+
params: { password: "<pw>", user: { email: "<email>" } }
325+
)
326+
}
327+
```
328+
329+
This will return a result similar to this, if your user has been successfully authenticated:
330+
331+
```json
332+
{
333+
"data": {
334+
"verifyAuthentication": true
335+
}
336+
}
337+
```
338+
260339
# GraphQL Client
261340

262341
_Client side graphql transport for accounts suite_

0 commit comments

Comments
 (0)