Skip to content

Commit 2cd622a

Browse files
committed
more migration
1 parent dbad5a9 commit 2cd622a

File tree

3 files changed

+55
-57
lines changed

3 files changed

+55
-57
lines changed

packages/web/docs/src/content/gateway/deployment/node-frameworks/fastify.mdx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@ So you can benefit from the powerful plugins of Fastify ecosystem with Hive Gate
1818

1919
## Example
2020

21-
In order to connect Fastify's logger to the gateway, you need to install the
22-
`@graphql-hive/logger-pino` package together with `@graphql-hive/gateway-runtime` and `fastify`.
23-
2421
```sh npm2yarn
25-
npm i @graphql-hive/gateway-runtime @graphql-hive/logger-pino fastify
22+
npm i @graphql-hive/gateway-runtime @graphql-hive/logger fastify
2623
```
2724

2825
```ts
2926
import fastify, { type FastifyReply, type FastifyRequest } from 'fastify'
30-
import { createGatewayRuntime } from '@graphql-hive/gateway-runtime'
31-
import { createLoggerFromPino } from '@graphql-hive/logger-pino'
27+
import { createGatewayRuntime, Logger } from '@graphql-hive/gateway-runtime'
28+
import { PinoLogWriter } from '@graphql-hive/logger/writers/pino'
3229

3330
// Request ID header used for tracking requests
3431
const requestIdHeader = 'x-request-id'
@@ -52,8 +49,10 @@ interface FastifyContext {
5249
}
5350

5451
const gateway = createGatewayRuntime<FastifyContext>({
55-
// Integrate Fastify's logger / Pino with the gateway logger
56-
logging: createLoggerFromPino(app.log),
52+
// Use Fastify's logger (Pino) with Hive Logger
53+
logging: new Logger({
54+
writers: [new PinoLogWriter(app.log)]
55+
}),
5756
// Align with Fastify
5857
requestId: {
5958
// Use the same header name as Fastify

packages/web/docs/src/content/gateway/other-features/custom-plugins.mdx

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ It have to be a function, which will be called each time the gateway have update
3939
For example, if polling is enabled, this function will be called for each poll.
4040

4141
Most Hive Gateway plugins takes an object as a parameter, and expect some common components like a
42-
`logger`, a `pubsub`, etc... Those components are given in parameters to the `plugins` function. It
43-
is advised to spread the plugin's factory context into the plugins options, this way plugins will
44-
have access to all components they need.
42+
`log`, a `pubsub`, etc... Those components are given in parameters to the `plugins` function. It is
43+
advised to spread the plugin's factory context into the plugins options, this way plugins will have
44+
access to all components they need.
4545

4646
```ts filename="gateway.config.ts"
4747
import { defineConfig } from '@graphql-hive/gateway'
@@ -172,7 +172,7 @@ Possible usage examples of the hooks are:
172172
| `setFetchFn` | Replace the `fetch` function that will be used to make the request. It should be compatible with standard `fetch` API. |
173173
| `executionRequest` | Present only if the request is an upstream subgraph request. It contains all information about the upstream query, notably the target subgraph name. |
174174
| `requestId` | A unique ID identifying the client request. This is used to correlate downstream and upstream requests across services. |
175-
| `logger` | The logger instance for the specific request that includes the details of the request and the response. |
175+
| `log` | The [Hive Logger](/docs/logger) instance for the specific request that includes the details of the request and the response. |
176176

177177
##### `onFetchDone`
178178

@@ -659,21 +659,21 @@ This hook has a before and after stage. You can return a function to hook into t
659659

660660
This hook is mostly used for monitoring and tracing purposes.
661661

662-
| Field Name | Description |
663-
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------- |
664-
| `supergraph` | The GraphQL schema of the supergraph. |
665-
| `subgraph` | The name of the subgraph. |
666-
| `sourceSubschema` | The schema of the subgraph. |
667-
| `typeName` | The name of the type being planed. |
668-
| `variables` | The variables provided in the client request. |
669-
| `fragments` | The fragments provided in the client request. |
670-
| `fieldNodes` | The field nodes of selection set being planned. |
671-
| `context` | The GraphQL context object. |
672-
| `requestId` | A unique ID identifying the client request. This is used to correlate downstream and upstream requests across services. |
673-
| `logger` | The logger instance for the specific request that includes the details of the request and the response. |
674-
| `info` | The `GraphQLResolveInfo` object of the client query. |
675-
| `delegationPlanBuilder` | The delegation plan builder. |
676-
| `setDelegationPlanBuilder` | Function to replace the current delegation plan builder. |
662+
| Field Name | Description |
663+
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
664+
| `supergraph` | The GraphQL schema of the supergraph. |
665+
| `subgraph` | The name of the subgraph. |
666+
| `sourceSubschema` | The schema of the subgraph. |
667+
| `typeName` | The name of the type being planed. |
668+
| `variables` | The variables provided in the client request. |
669+
| `fragments` | The fragments provided in the client request. |
670+
| `fieldNodes` | The field nodes of selection set being planned. |
671+
| `context` | The GraphQL context object. |
672+
| `requestId` | A unique ID identifying the client request. This is used to correlate downstream and upstream requests across services. |
673+
| `log` | The [Hive Logger](/docs/logger) instance for the specific request that includes the details of the request and the response. |
674+
| `info` | The `GraphQLResolveInfo` object of the client query. |
675+
| `delegationPlanBuilder` | The delegation plan builder. |
676+
| `setDelegationPlanBuilder` | Function to replace the current delegation plan builder. |
677677

678678
##### `onDelegationPlanDone`
679679

@@ -694,21 +694,21 @@ requires multiple stages to be fully resolved.
694694
This hooks has a before and after stage. You can return a function to hook into the after stage (see
695695
[`onDelegationStageExecuteDone`](#ondelegationstageexecutedone)).
696696

697-
| Payload Field | Description |
698-
| -------------- | ----------------------------------------------------------------------------------------------------------------------- |
699-
| `object` | The object being resolved. |
700-
| `context` | The GraphQL context object. |
701-
| `info` | The `GraphQLResolveInfo` object. |
702-
| `subgraph` | The name of the subgraph. |
703-
| `subschema` | The schema of the current subgraph. |
704-
| `selectionSet` | The selection set node that will be queried. |
705-
| `key` | The key for the entity being resolved. |
706-
| `type` | The type of the entity being resolved. |
707-
| `typeName` | The name of the type being resolved. |
708-
| `resolver` | The resolver function for the merged type. |
709-
| `setResolver` | Function to set a new resolver for the merged type. |
710-
| `requestId` | A unique ID identifying the client request. This is used to correlate downstream and upstream requests across services. |
711-
| `logger` | The logger instance for the specific request that includes the details of the request and the response. |
697+
| Payload Field | Description |
698+
| -------------- | ---------------------------------------------------------------------------------------------------------------------------- |
699+
| `object` | The object being resolved. |
700+
| `context` | The GraphQL context object. |
701+
| `info` | The `GraphQLResolveInfo` object. |
702+
| `subgraph` | The name of the subgraph. |
703+
| `subschema` | The schema of the current subgraph. |
704+
| `selectionSet` | The selection set node that will be queried. |
705+
| `key` | The key for the entity being resolved. |
706+
| `type` | The type of the entity being resolved. |
707+
| `typeName` | The name of the type being resolved. |
708+
| `resolver` | The resolver function for the merged type. |
709+
| `setResolver` | Function to set a new resolver for the merged type. |
710+
| `requestId` | A unique ID identifying the client request. This is used to correlate downstream and upstream requests across services. |
711+
| `log` | The [Hive Logger](/docs/logger) instance for the specific request that includes the details of the request and the response. |
712712

713713
##### `onDelegationStageExecuteDone`
714714

@@ -733,17 +733,17 @@ This hook is invoked for ANY request that is sent to the subgraph.
733733
You can see [Prometheus plugin](/docs/gateway/authorization-authentication) for an example of how to
734734
use this hook.
735735

736-
| Payload Field | Description |
737-
| --------------------- | ------------------------------------------------------------------------------------------------------- |
738-
| `subgraph` | The GraphQL schema of the subgraph. |
739-
| `subgraphName` | The name of the subgraph. |
740-
| `transportEntry` | The transport entry that will be used to resolve queries for this subgraph |
741-
| `executionRequest` | The execution request object containing details of the upstream GraphQL operation. |
742-
| `setExecutionRequest` | Function to replace the current execution request. |
743-
| `executor` | The executor function used to execute the upstream request. |
744-
| `setExecutor` | Function to replace the current executor. |
745-
| `requestId` | A unique ID identifying the client request. |
746-
| `logger` | The logger instance for the specific request that includes the details of the request and the response. |
736+
| Payload Field | Description |
737+
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
738+
| `subgraph` | The GraphQL schema of the subgraph. |
739+
| `subgraphName` | The name of the subgraph. |
740+
| `transportEntry` | The transport entry that will be used to resolve queries for this subgraph |
741+
| `executionRequest` | The execution request object containing details of the upstream GraphQL operation. |
742+
| `setExecutionRequest` | Function to replace the current execution request. |
743+
| `executor` | The executor function used to execute the upstream request. |
744+
| `setExecutor` | Function to replace the current executor. |
745+
| `requestId` | A unique ID identifying the client request. |
746+
| `log` | The [Hive Logger](/docs/logger) instance for the specific request that includes the details of the request and the response. |
747747

748748
##### `onSubgraphExecuteDone`
749749

@@ -1040,7 +1040,7 @@ return a `Promise` if `wrapped()` returns a `Promise`.
10401040

10411041
### Plugin Context
10421042

1043-
Hive Gateway comes with ready-to-use `logger`, `fetch`, cache storage and etc that are shared across
1043+
Hive Gateway comes with ready-to-use `log`, `fetch`, cache storage and etc that are shared across
10441044
different components. We'd highly recommend you to use those available context values instead of
10451045
creating your own for a specific plugin.
10461046

@@ -1050,13 +1050,13 @@ import { defineConfig } from '@graphql-hive/gateway'
10501050
export const gatewayConfig = defineConfig({
10511051
plugins({
10521052
fetch, // WHATWG compatible Fetch implementation.
1053-
logger, // Logger instance used by Hive Gateway
1053+
log, // Hive Logger instance used by Hive Gateway
10541054
cwd, // Current working directory
10551055
pubsub, // PubSub instance used by Hive Gateway
10561056
cache // Cache storage used by Hive Gateway
10571057
}) {
10581058
return [
1059-
useMyPlugin({ logger, fetch }) // So the plugin can use the shared logger and fetch
1059+
useMyPlugin({ log, fetch }) // So the plugin can use the shared logger and fetch
10601060
]
10611061
}
10621062
})

packages/web/docs/src/content/gateway/other-features/performance/index.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ export default {
156156
session: () => null
157157
},
158158
cache: new CloudflareKVCacheStorage({
159-
logger,
160159
namespace: env.NAMESPACE
161160
})
162161
})

0 commit comments

Comments
 (0)