Skip to content

Commit 6d0f201

Browse files
committed
more migration
1 parent 3059e0c commit 6d0f201

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

@@ -828,7 +828,7 @@ Prefer `onRequestParse` when possible, or wrap the hook code in a `try` block.
828828

829829
### Plugin Context
830830

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

@@ -838,13 +838,13 @@ import { defineConfig } from '@graphql-hive/gateway'
838838
export const gatewayConfig = defineConfig({
839839
plugins({
840840
fetch, // WHATWG compatible Fetch implementation.
841-
logger, // Logger instance used by Hive Gateway
841+
log, // Hive Logger instance used by Hive Gateway
842842
cwd, // Current working directory
843843
pubsub, // PubSub instance used by Hive Gateway
844844
cache // Cache storage used by Hive Gateway
845845
}) {
846846
return [
847-
useMyPlugin({ logger, fetch }) // So the plugin can use the shared logger and fetch
847+
useMyPlugin({ log, fetch }) // So the plugin can use the shared logger and fetch
848848
]
849849
}
850850
})

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)