msw 2.4.0 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@
8
8
  * - Please do NOT serve this file on production.
9
9
  */
10
10
 
11
- const PACKAGE_VERSION = '2.4.0'
11
+ const PACKAGE_VERSION = '2.4.2'
12
12
  const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
13
13
  const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
14
14
  const activeClientIds = new Set()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "msw",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "Seamless REST/GraphQL API mocking library for browser and Node.js.",
5
5
  "main": "./lib/core/index.js",
6
6
  "module": "./lib/core/index.mjs",
@@ -180,7 +180,8 @@
180
180
  "webpack-http-server": "^0.5.0"
181
181
  },
182
182
  "peerDependencies": {
183
- "typescript": ">= 4.7.x"
183
+ "graphql": ">= 16.8.x",
184
+ "typescript": ">= 4.8.x"
184
185
  },
185
186
  "peerDependenciesMeta": {
186
187
  "graphql": {
@@ -3,7 +3,6 @@ import type {
3
3
  OperationDefinitionNode,
4
4
  OperationTypeNode,
5
5
  } from 'graphql'
6
- import { parse } from 'graphql'
7
6
  import type { GraphQLVariables } from '../../handlers/GraphQLHandler'
8
7
  import { toPublicUrl } from '../request/toPublicUrl'
9
8
  import { devUtils } from './devUtils'
@@ -40,7 +39,16 @@ export function parseDocumentNode(node: DocumentNode): ParsedGraphQLQuery {
40
39
  }
41
40
  }
42
41
 
43
- function parseQuery(query: string): ParsedGraphQLQuery | Error {
42
+ async function parseQuery(query: string): Promise<ParsedGraphQLQuery | Error> {
43
+ /**
44
+ * @note Use `require` to get the "graphql" module here.
45
+ * It has to be scoped to this function because this module leaks to the
46
+ * root export. It has to be `require` because tools like Jest have trouble
47
+ * handling dynamic imports. It gets replaced with a dynamic import on build time.
48
+ */
49
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
50
+ const { parse } = require('graphql')
51
+
44
52
  try {
45
53
  const ast = parse(query)
46
54
  return parseDocumentNode(ast)
@@ -181,7 +189,7 @@ export async function parseGraphQLRequest(
181
189
  }
182
190
 
183
191
  const { query, variables } = input
184
- const parsedResult = parseQuery(query)
192
+ const parsedResult = await parseQuery(query)
185
193
 
186
194
  if (parsedResult instanceof Error) {
187
195
  const requestPublicUrl = toPublicUrl(request.url)