Skip to content

Commit

Permalink
docs: app deployments (persisted documents) (#5281)
Browse files Browse the repository at this point in the history
Co-authored-by: Saihajpreet Singh <[email protected]>
  • Loading branch information
n1ru4l and saihaj authored Aug 1, 2024
1 parent 9244b26 commit 5953562
Show file tree
Hide file tree
Showing 13 changed files with 559 additions and 6 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 76 additions & 0 deletions packages/web/docs/src/pages/docs/api-reference/client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,82 @@ useHive({

</Tabs>

#### Persisted Documents

Hive client supports resolving persisted documents. For getting started please refer to our
[App Deployments (Persisted Documents) documentation](/docs/features/app-deployments).

##### Basic Configuration

For enabling you need to provide the `experimental__persistedDocuments` as follows.

```ts filename="Hive Persisted Documents Basic Configuration"
useHive({
experimental__persistedDocuments: {
cdn: {
// replace <target_id> and <cdn_access_token> with your values
endpoint: 'https://cdn.graphql-hive.com/<target_id>',
accessToken: '<cdn_access_token>'
}
}
})
```

##### Allow arbitrary documents

By default, Hive client plugins will only allow executing documents that are registered in the
Schema Registry. If you want to allow arbitrary documents to be executed, you can set the
`allowArbitraryDocuments` option to `true`.

```typescript filename="Hive Persisted Documents Allow Arbitrary Documents" {8}
useHive({
experimental__persistedDocuments: {
cdn: {
// replace <target_id> and <cdn_access_token> with your values
endpoint: 'https://cdn.graphql-hive.com/<target_id>',
accessToken: '<cdn_access_token>'
},
allowArbitraryDocuments: true
}
})
```

Furthermore, you can also allow arbitraty documents based on the incoming HTTP request.

```typescript filename="Hive Persisted Documents Allow Arbitrary Documents Based on Request" {8-9}
useHive({
experimental__persistedDocuments: {
cdn: {
// replace <target_id> and <cdn_access_token> with your values
endpoint: 'https://cdn.graphql-hive.com/<target_id>',
accessToken: '<cdn_access_token>'
},
allowArbitraryDocuments: context =>
context.headers.get('x-arbitrary-documents') === '<my-secret-key>'
}
})
```

##### Cache size

By default, the client will cache up to 10.000 documents loaded from the CDN in memory to avoid
redundant lookups and speedup reoccuring document executions. You can change this value by setting
the `cache` option.

```typescript filename="Hive Persisted Documents Cache Size" {8-9}
useHive({
experimental__persistedDocuments: {
cdn: {
// replace <target_id> and <cdn_access_token> with your values
endpoint: 'https://cdn.graphql-hive.com/<target_id>',
accessToken: '<cdn_access_token>'
},
// Cache up to 50.000 documents
cache: 50_000
}
})
```

#### Custom Integration

If your GraphQL server is not listed above, you can implement a custom integration. Start by
Expand Down
1 change: 1 addition & 0 deletions packages/web/docs/src/pages/docs/features/_meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export default {
'high-availability-cdn': 'High-Availability CDN',
'schema-policy': 'Schema Policies',
laboratory: 'Laboratory',
'app-deployments': 'App Deployments (Persisted Documents)',
};
Loading

0 comments on commit 5953562

Please sign in to comment.