Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): include "graphql" as a dependency #1381

Merged
merged 5 commits into from Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions package.json
Expand Up @@ -77,6 +77,7 @@
"chalk": "4.1.1",
"chokidar": "^3.4.2",
"cookie": "^0.4.2",
"graphql": "^15.0.0 || ^16.0.0",
kettanaito marked this conversation as resolved.
Show resolved Hide resolved
"headers-polyfill": "^3.0.4",
"inquirer": "^8.2.0",
"is-node-process": "^1.0.1",
Expand Down Expand Up @@ -115,7 +116,6 @@
"eslint-plugin-prettier": "^3.4.0",
"fs-extra": "^10.0.0",
"fs-teardown": "^0.3.0",
"graphql": "^16.3.0",
"jest": "26",
"json-bigint": "^1.0.0",
"lint-staged": "^11.0.1",
Expand All @@ -134,13 +134,9 @@
"webpack-dev-server": "^3.11.2"
},
"peerDependencies": {
"graphql": "^15.0.0 || ^16.0.0",
"typescript": ">= 4.2.x <= 4.8.x"
},
"peerDependenciesMeta": {
"graphql": {
"optional": true
kettanaito marked this conversation as resolved.
Show resolved Hide resolved
},
"typescript": {
"optional": true
}
Expand All @@ -153,4 +149,4 @@
"path": "./node_modules/cz-conventional-changelog"
}
}
}
}
4 changes: 1 addition & 3 deletions src/utils/internal/parseGraphQLRequest.ts
Expand Up @@ -3,6 +3,7 @@ import type {
OperationDefinitionNode,
OperationTypeNode,
} from 'graphql'
import { parse } from 'graphql'
kettanaito marked this conversation as resolved.
Show resolved Hide resolved
import { GraphQLVariables } from '../../handlers/GraphQLHandler'
import { getPublicUrlFromRequest } from '../request/getPublicUrlFromRequest'
import { MockedRequest } from '../request/MockedRequest'
Expand Down Expand Up @@ -40,9 +41,6 @@ export function parseDocumentNode(node: DocumentNode): ParsedGraphQLQuery {

function parseQuery(query: string): ParsedGraphQLQuery | Error {
try {
// Since 'graphql' is an optional peer dependency,
// we'll attempt to import it dynamically
const { parse } = require('graphql')
const ast = parse(query)
return parseDocumentNode(ast)
} catch (error) {
Expand Down
3 changes: 1 addition & 2 deletions test/graphql-api/compatibility.node.test.ts
@@ -1,6 +1,5 @@
import fetch from 'cross-fetch'
import { graphql as executeGraphql } from 'graphql'
import { buildSchema } from 'graphql/utilities'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use this from /utilities and from graphql in different files, so I moved to just using the base package export

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 agree with this. We should rely on the base package all the time.

import { graphql as executeGraphql, buildSchema } from 'graphql'
import { graphql } from 'msw'
import { setupServer } from 'msw/node'
import { createGraphQLClient, gql } from '../support/graphql'
Expand Down
9 changes: 3 additions & 6 deletions test/graphql-api/extensions.node.test.ts
@@ -1,14 +1,11 @@
/**
* @jest-environment node
*/
import fetch from 'node-fetch'
import {
graphql as executeGraphql,
buildSchema,
ExecutionResult,
} from 'graphql'
import type { ExecutionResult } from 'graphql'
import { buildSchema, graphql as executeGraphql } from 'graphql'
import { graphql } from 'msw'
import { setupServer } from 'msw/node'
import fetch from 'node-fetch'
import { gql } from '../support/graphql'

const schema = gql`
Expand Down
2 changes: 1 addition & 1 deletion test/graphql-api/extensions.test.ts
@@ -1,6 +1,6 @@
import * as path from 'path'
import { pageWith } from 'page-with'
import { ExecutionResult } from 'graphql'
import type { ExecutionResult } from 'graphql'
import { executeGraphQLQuery } from './utils/executeGraphQLQuery'
import { gql } from '../support/graphql'

Expand Down
3 changes: 1 addition & 2 deletions test/graphql-api/response-patching.node.test.ts
Expand Up @@ -4,8 +4,7 @@
import { graphql } from 'msw'
import { setupServer } from 'msw/node'
import fetch from 'cross-fetch'
import { graphql as executeGraphql } from 'graphql'
import { buildSchema } from 'graphql/utilities'
import { graphql as executeGraphql, buildSchema } from 'graphql'
import { ServerApi, createServer } from '@open-draft/test-server'
import { createGraphQLClient, gql } from '../support/graphql'

Expand Down
3 changes: 2 additions & 1 deletion test/graphql-api/response-patching.test.ts
@@ -1,6 +1,7 @@
import * as path from 'path'
import { pageWith } from 'page-with'
import { ExecutionResult, buildSchema, graphql } from 'graphql'
import type { ExecutionResult } from 'graphql'
import { buildSchema, graphql } from 'graphql'
import { ServerApi, createServer } from '@open-draft/test-server'
import { SetupWorkerApi } from 'msw'
import { gql } from '../support/graphql'
Expand Down
2 changes: 1 addition & 1 deletion test/support/graphql.ts
@@ -1,4 +1,4 @@
import { ExecutionResult } from 'graphql'
import type { ExecutionResult } from 'graphql'

/**
* Identity function that returns a given template string array.
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -5345,10 +5345,10 @@ graceful-fs@^4.2.9:
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.9.tgz#041b05df45755e587a24942279b9d113146e1c96"
integrity sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==

graphql@^16.3.0:
version "16.3.0"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.3.0.tgz#a91e24d10babf9e60c706919bb182b53ccdffc05"
integrity sha512-xm+ANmA16BzCT5pLjuXySbQVFwH3oJctUVdy81w1sV0vBU0KgDdBGtxQOUd5zqOBk/JayAFeG8Dlmeq74rjm/A==
"graphql@^15.0.0 || ^16.0.0":
version "16.6.0"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.6.0.tgz#c2dcffa4649db149f6282af726c8c83f1c7c5fdb"
integrity sha512-KPIBPDlW7NxrbT/eh4qPXz5FiFdL5UbaA0XUNz2Rp3Z3hqBSkbj0GVjwFDztsWVauZUWsbKHgMg++sk8UX0bkw==

growly@^1.3.0:
version "1.3.0"
Expand Down