@@ -9,12 +9,21 @@ import { Callout } from '@theguild/components'
99Mocking your GraphQL API is a common practice when developing and testing your application. It
1010allows you to simulate the behavior of your API without making real network requests.
1111
12+ ## Installing
13+
14+ Start by installing the ` @graphql-mesh/plugin-mock ` package:
15+
16+ ``` sh npm2yarn
17+ npm i @graphql-mesh/plugin-mock
18+ ```
19+
1220## How to use?
1321
1422Add it to your plugins:
1523
1624``` ts filename="gateway.config.ts"
17- import { defineConfig , useMock } from ' @graphql-hive/gateway'
25+ import { defineConfig } from ' @graphql-hive/gateway'
26+ import { useMock } from ' @graphql-mesh/plugin-mock'
1827
1928export const gatewayConfig = defineConfig ({
2029 plugins: [
@@ -38,7 +47,8 @@ The example above will replace the resolver of `User.firstName` with a mock that
3847You can also provide a custom function to generate the mock value for a field:
3948
4049``` ts filename="gateway.config.ts"
41- import { defineConfig , useMock } from ' @graphql-hive/gateway'
50+ import { defineConfig } from ' @graphql-hive/gateway'
51+ import { useMock } from ' @graphql-mesh/plugin-mock'
4252import { fullName } from ' ./user-mocks.js'
4353
4454export const gatewayConfig = defineConfig ({
@@ -60,7 +70,8 @@ export const gatewayConfig = defineConfig({
6070You can mock types with custom mock functions like below;
6171
6272``` ts filename="gateway.config.ts"
63- import { defineConfig , useMock } from ' @graphql-hive/gateway'
73+ import { defineConfig } from ' @graphql-hive/gateway'
74+ import { useMock } from ' @graphql-mesh/plugin-mock'
6475import { user } from ' ./user-mocks.js'
6576
6677export const gatewayConfig = defineConfig ({
@@ -116,7 +127,8 @@ type User {
116127```
117128
118129```ts filename ="gateway.config.ts"
119- import { defineConfig , useMock } from '@graphql -hive /gateway '
130+ import { defineConfig } from '@graphql -hive /gateway '
131+ import { useMock } from '@graphql -mesh /plugin -mock '
120132
121133export const gatewayConfig = defineConfig ({
122134 plugins : pluginCtx => [
@@ -160,7 +172,7 @@ using the store provided in the context `context.mockStore`;
160172When having a schema that returns a list, in this case, a list of users:
161173
162174``` ts filename="init-store.ts"
163- import { MockStore } from ' @graphql-hive/gateway '
175+ import { MockStore } from ' @graphql-mesh/plugin-mock '
164176
165177export const store = new MockStore ()
166178const users = [{ id: ' uuid' , name: ' John Snow' }]
@@ -184,7 +196,8 @@ type Query {
184196```
185197
186198```ts filename ="gateway.config.ts"
187- import { defineConfig , useMock } from '@graphql -hive /gateway '
199+ import { defineConfig } from '@graphql -hive /gateway '
200+ import { useMock } from '@graphql -mesh /plugin -mock '
188201import { store } from './init -store .js '
189202
190203export const gatewayConfig = defineConfig ({
@@ -219,7 +232,8 @@ type Mutation {
219232```
220233
221234```ts filename ="gateway.config.ts"
222- import { defineConfig , useMock } from '@graphql -hive /gateway '
235+ import { defineConfig } from '@graphql -hive /gateway '
236+ import { useMock } from '@graphql -mesh /plugin -mock '
223237import { store } from './init -store .js '
224238
225239export const gatewayConfig = defineConfig ({
0 commit comments