diff --git a/package.json b/package.json index 1a858e7d6e110..45c6a4f99965f 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "fbjs": "^1.0.0", "fbjs-scripts": "^1.1.0", "flow-bin": "^0.102.0", - "graphql": "^14.2.0", + "graphql": "^14.4.0", "gulp": "4.0.0", "gulp-babel": "8.0.0", "gulp-chmod": "2.0.0", diff --git a/packages/babel-plugin-relay/__tests__/__snapshots__/BabelPluginRelay-classic-test.js.snap b/packages/babel-plugin-relay/__tests__/__snapshots__/BabelPluginRelay-classic-test.js.snap index f098375e892f1..5a073fa1e6a8a 100644 --- a/packages/babel-plugin-relay/__tests__/__snapshots__/BabelPluginRelay-classic-test.js.snap +++ b/packages/babel-plugin-relay/__tests__/__snapshots__/BabelPluginRelay-classic-test.js.snap @@ -43,7 +43,7 @@ GraphQL Validation Error: Expected type Boolean, found "true". > > isViewerFriend: "true" > ^^^ -GraphQL Validation Error: Expected type Gender, found "MALE"; Did you mean the enum value MALE or FEMALE? +GraphQL Validation Error: Expected type Gender, found "MALE". Did you mean the enum value MALE or FEMALE? > > gender: "MALE" > ^^^ diff --git a/packages/babel-plugin-relay/package.json b/packages/babel-plugin-relay/package.json index 859e6262516d5..bc7d1e985ab98 100644 --- a/packages/babel-plugin-relay/package.json +++ b/packages/babel-plugin-relay/package.json @@ -16,6 +16,6 @@ "babel-plugin-macros": "^2.0.0" }, "peerDependencies": { - "graphql": "^14.2.0" + "graphql": "^14.4.0" } } diff --git a/packages/relay-compiler/codegen/__tests__/__snapshots__/compileRelayArtifacts-test.js.snap b/packages/relay-compiler/codegen/__tests__/__snapshots__/compileRelayArtifacts-test.js.snap index 4d486de33ea03..c9c6a8147cf12 100644 --- a/packages/relay-compiler/codegen/__tests__/__snapshots__/compileRelayArtifacts-test.js.snap +++ b/packages/relay-compiler/codegen/__tests__/__snapshots__/compileRelayArtifacts-test.js.snap @@ -1471,11 +1471,11 @@ THROWN EXCEPTION: ReaderCodeGenerator: Complex argument values (Lists or InputObjects with nested variables) are not supported. -Source: GraphQL request (3:17) -2: query TestQuery($date: String) { -3: items(filter: {date: $date}) { - ^ -4: date +Source: GraphQL request:3:17 +2 | query TestQuery($date: String) { +3 | items(filter: {date: $date}) { + | ^ +4 | date `; @@ -3287,17 +3287,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Invalid use of @connection_resolver, could not generate a default label that is unique. Specify a unique 'label' as a literal string. - Source: GraphQL request (20:25) - 19: ... { - 20: comments(first: 10) @connection_resolver(resolver: "FeedbackCommentsEdgesResolver") { #error: same default label - ^ - 21: count + Source: GraphQL request:20:25 + 19 | ... { + 20 | comments(first: 10) @connection_resolver(resolver: "FeedbackCommentsEdgesResolver") { #error: same default label + | ^ + 21 | count - Source: GraphQL request (9:23) - 8: fragment FeedbackComments_feedback on Feedback { - 9: comments(first: 10) @connection_resolver(resolver: "FeedbackCommentsEdgesResolver") { - ^ - 10: edges { + Source: GraphQL request:9:23 + 8 | fragment FeedbackComments_feedback on Feedback { + 9 | comments(first: 10) @connection_resolver(resolver: "FeedbackCommentsEdgesResolver") { + | ^ + 10 | edges { `; @@ -3334,17 +3334,16 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Invalid use of @connection_resolver, the provided label is not unique. Specify a unique 'label' as a literal string. - Source: GraphQL request (20:89) - 19: ... { - 20: comments(first: 10) @connection_resolver(resolver: "FeedbackCommentsEdgesResolver", label: "comments") { #error: same label - ^ - 21: count + Source: GraphQL request:20:89 + 20 | comments(first: 10) @connection_resolver(resolver: "FeedbackCommentsEdgesRes + | olver", label: "comments") { #error: same label + | ^ - Source: GraphQL request (9:87) - 8: fragment FeedbackComments_feedback on Feedback { - 9: comments(first: 10) @connection_resolver(resolver: "FeedbackCommentsEdgesResolver", label: "comments") { - ^ - 10: edges { # error: plural + Source: GraphQL request:9:87 + 8 | fragment FeedbackComments_feedback on Feedback { + 9 | comments(first: 10) @connection_resolver(resolver: "FeedbackCommentsEdgesResolver", label: "comments") { + | ^ + 10 | edges { # error: plural `; @@ -3376,11 +3375,11 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - @connection_resolver fields must return a single value, not a list, found '[CommentsEdge]' - Source: GraphQL request (10:5) - 9: comments(first: 10) { - 10: edges @connection_resolver(resolver: "FeedbackCommentsEdgesResolver") { # error: plural - ^ - 11: node { + Source: GraphQL request:10:5 + 9 | comments(first: 10) { + 10 | edges @connection_resolver(resolver: "FeedbackCommentsEdgesResolver") { # error: plural + | ^ + 11 | node { `; @@ -3403,11 +3402,11 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - The @connection_resolver direction is not supported on scalar fields, only fields returning an object/interface/union - Source: GraphQL request (9:6) - 8: fragment FeedbackComments_feedback on Feedback { - 9: id @connection_resolver(resolver: "FeedbackIDResolver") # error: scalar - ^ - 10: } + Source: GraphQL request:9:6 + 8 | fragment FeedbackComments_feedback on Feedback { + 9 | id @connection_resolver(resolver: "FeedbackIDResolver") # error: scalar + | ^ + 10 | } `; @@ -4657,20 +4656,20 @@ Error: Encountered 2 error(s): - Operation 'FeedbackQuery' references undefined variable(s): - $commentsKey: String. - Source (derived): GraphQL request (25:26) - 24: key: "FeedbackFragment_comments" - 25: dynamicKey_UNSTABLE: $commentsKey - ^ - 26: filters: ["orderby"] + Source (derived): GraphQL request:25:26 + 24 | key: "FeedbackFragment_comments" + 25 | dynamicKey_UNSTABLE: $commentsKey + | ^ + 26 | filters: ["orderby"] - Operation 'PaginationQuery' references undefined variable(s): - $commentsKey: String. - Source (derived): GraphQL request (25:26) - 24: key: "FeedbackFragment_comments" - 25: dynamicKey_UNSTABLE: $commentsKey - ^ - 26: filters: ["orderby"] + Source (derived): GraphQL request:25:26 + 24 | key: "FeedbackFragment_comments" + 25 | dynamicKey_UNSTABLE: $commentsKey + | ^ + 26 | filters: ["orderby"] `; @@ -5899,35 +5898,33 @@ THROWN EXCEPTION: Error: Found a circular reference from fragment 'Profile'. -Source (derived): GraphQL request (2:1) -1: # expected-to-throw -2: fragment RefetchableFragment on Query @refetchable(queryName: "RefetchableFragmentQuery") @argumentDefinitions(id: {type: "ID!"}) { - ^ -3: node(id: $id) { - -Source (derived): GraphQL request (2:1) -1: # expected-to-throw -2: fragment RefetchableFragment on Query @refetchable(queryName: "RefetchableFragmentQuery") @argumentDefinitions(id: {type: "ID!"}) { - ^ -3: node(id: $id) { - -Source: GraphQL request (7:7) -6: name -7: ...Profile @arguments(includeProfile: true) - ^ -8: } - -Source: GraphQL request (21:9) -20: node { -21: ...Profile - ^ -22: } - -Source: GraphQL request (21:9) -20: node { -21: ...Profile - ^ -22: } +Source (derived): GraphQL request:2:1 +2 | fragment RefetchableFragment on Query @refetchable(queryName: "RefetchableFragme + | ^ + | ntQuery") @argumentDefinitions(id: {type: "ID!"}) { + +Source (derived): GraphQL request:2:1 +2 | fragment RefetchableFragment on Query @refetchable(queryName: "RefetchableFragme + | ^ + | ntQuery") @argumentDefinitions(id: {type: "ID!"}) { + +Source: GraphQL request:7:7 +6 | name +7 | ...Profile @arguments(includeProfile: true) + | ^ +8 | } + +Source: GraphQL request:21:9 +20 | node { +21 | ...Profile + | ^ +22 | } + +Source: GraphQL request:21:9 +20 | node { +21 | ...Profile + | ^ +22 | } `; @@ -6675,17 +6672,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Unexpected directive: @defer. This directive can only be used on fields/fragments that are fetched from the server schema, but it is used inside a client-only selection. - Source (derived): GraphQL request (12:23) - 11: emailAddresses - 12: ...DeferredFragment @defer(label: "DeferredFragmentLabel") - ^ - 13: } + Source (derived): GraphQL request:12:23 + 11 | emailAddresses + 12 | ...DeferredFragment @defer(label: "DeferredFragmentLabel") + | ^ + 13 | } - Source (derived): GraphQL request (12:3) - 11: emailAddresses - 12: ...DeferredFragment @defer(label: "DeferredFragmentLabel") - ^ - 13: } + Source (derived): GraphQL request:12:3 + 11 | emailAddresses + 12 | ...DeferredFragment @defer(label: "DeferredFragmentLabel") + | ^ + 13 | } `; @@ -7082,17 +7079,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Cannot use @relay(mask: false) on fragment spreads for fragments with directives. - Source: GraphQL request (5:5) - 4: me { - 5: ...Profile @relay(mask: false) - ^ - 6: } + Source: GraphQL request:5:5 + 4 | me { + 5 | ...Profile @relay(mask: false) + | ^ + 6 | } - Source: GraphQL request (9:26) - 8: - 9: fragment Profile on User @inline { - ^ - 10: id + Source: GraphQL request:9:26 + 8 | + 9 | fragment Profile on User @inline { + | ^ + 10 | id `; @@ -7482,11 +7479,11 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Variables are not yet supported inside @inline fragments. - Source: GraphQL request (10:24) - 9: fragment Profile on User @inline { - 10: profilePicture(size: $pictureSize) { - ^ - 11: uri + Source: GraphQL request:10:24 + 9 | fragment Profile on User @inline { + 10 | profilePicture(size: $pictureSize) { + | ^ + 11 | uri `; @@ -7520,11 +7517,11 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Variables are not yet supported inside @inline fragments. - Source: GraphQL request (17:24) - 16: @inline - 17: @argumentDefinitions(sizeArg: { type: "[Int]", defaultValue: [50] }) { - ^ - 18: profilePicture(size: $sizeArg) { + Source: GraphQL request:17:24 + 16 | @inline + 17 | @argumentDefinitions(sizeArg: { type: "[Int]", defaultValue: [50] }) { + | ^ + 18 | profilePicture(size: $sizeArg) { `; @@ -8329,17 +8326,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Found conflicting @module selections: use a unique alias on the parent fields. - Source: GraphQL request (22:7) - 21: ...MarkdownUserNameRenderer_name - 22: @module(name: "BarMarkdownUserNameRenderer.react") - ^ - 23: } + Source: GraphQL request:22:7 + 21 | ...MarkdownUserNameRenderer_name + 22 | @module(name: "BarMarkdownUserNameRenderer.react") + | ^ + 23 | } - Source: GraphQL request (13:7) - 12: ...MarkdownUserNameRenderer_name - 13: @module(name: "FooMarkdownUserNameRenderer.react") - ^ - 14: } + Source: GraphQL request:13:7 + 12 | ...MarkdownUserNameRenderer_name + 13 | @module(name: "FooMarkdownUserNameRenderer.react") + | ^ + 14 | } `; @@ -8531,17 +8528,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Required argument 'capitalize: Boolean!' is missing on 'nameWithArgs' in 'TestQuery'. - Source: GraphQL request (5:7) - 4: hometown{ - 5: nameWithArgs - ^ - 6: } + Source: GraphQL request:5:7 + 4 | hometown{ + 5 | nameWithArgs + | ^ + 6 | } - Source: GraphQL request (2:1) - 1: # expected-to-throw - 2: query TestQuery { - ^ - 3: node { + Source: GraphQL request:2:1 + 1 | # expected-to-throw + 2 | query TestQuery { + | ^ + 3 | node { `; @@ -9220,17 +9217,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Found conflicting @module selections: use a unique alias on the parent fields. - Source: GraphQL request (25:7) - 24: ...MarkdownUserNameRenderer_name - 25: @module(name: "BarMarkdownUserNameRenderer.react") - ^ - 26: } + Source: GraphQL request:25:7 + 24 | ...MarkdownUserNameRenderer_name + 25 | @module(name: "BarMarkdownUserNameRenderer.react") + | ^ + 26 | } - Source: GraphQL request (13:7) - 12: ...MarkdownUserNameRenderer_name - 13: @module(name: "FooMarkdownUserNameRenderer.react") - ^ - 14: ...PlainUserNameRenderer_name + Source: GraphQL request:13:7 + 12 | ...MarkdownUserNameRenderer_name + 13 | @module(name: "FooMarkdownUserNameRenderer.react") + | ^ + 14 | ...PlainUserNameRenderer_name `; @@ -15408,17 +15405,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - RelayMaskTransform: Cannot use @relay(mask: false) on fragment spread because the fragment definition uses @argumentDefinitions. - Source: GraphQL request (5:5) - 4: me { - 5: ...User_user @relay(mask: false) - ^ - 6: } + Source: GraphQL request:5:5 + 4 | me { + 5 | ...User_user @relay(mask: false) + | ^ + 6 | } - Source: GraphQL request (10:24) - 9: fragment User_user on User - 10: @argumentDefinitions(isRelative: {type: "Boolean!", defaultValue: false}) { - ^ - 11: + Source: GraphQL request:10:24 + 9 | fragment User_user on User + 10 | @argumentDefinitions(isRelative: {type: "Boolean!", defaultValue: false}) { + | ^ + 11 | `; @@ -15834,18 +15831,17 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Variable @arguments values are only supported when the argument is defined with @argumentDefinitions. Check the definition of fragment 'ProfilePhoto'. - GraphQL request (16:36) - 15: __typename - 16: ...ProfilePhoto @arguments(size: $size) - ^ - 17: } - - GraphQL request (19:1) - 18: - 19: fragment ProfilePhoto on User { - ^ - 20: profilePicture(size: [100]) { + GraphQL request:16:36 + 15 | __typename + 16 | ...ProfilePhoto @arguments(size: $size) + | ^ + 17 | } + GraphQL request:19:1 + 18 | + 19 | fragment ProfilePhoto on User { + | ^ + 20 | profilePicture(size: [100]) { `; exports[`compileRelayArtifacts matches expected output: unused-fragment-argdef-unchecked.graphql 1`] = ` diff --git a/packages/relay-compiler/core/RelayCompilerError.js b/packages/relay-compiler/core/RelayCompilerError.js index 3c100668a9a9b..2772327ce608b 100644 --- a/packages/relay-compiler/core/RelayCompilerError.js +++ b/packages/relay-compiler/core/RelayCompilerError.js @@ -10,7 +10,7 @@ 'use strict'; -const {GraphQLError} = require('graphql'); +const {GraphQLError, getLocation, printSourceLocation} = require('graphql'); import type {Location} from './GraphQLIR'; import type {ASTNode, Source, SourceLocation} from 'graphql'; @@ -164,7 +164,7 @@ function printLocations(locations: $ReadOnlyArray): Array { sourceLocation === location ? 'Source: ' : 'Source (derived): '; printedLocations.push( prefix + - highlightSourceAtLocation( + printSourceLocation( sourceLocation.source, getLocation(sourceLocation.source, sourceLocation.start), ), @@ -192,70 +192,6 @@ function printLocations(locations: $ReadOnlyArray): Array { return printedLocations; } -/** - * Render a helpful description of the location of the error in the GraphQL - * Source document. - */ -function highlightSourceAtLocation( - source: Source, - location: SourceLocation, -): string { - const firstLineColumnOffset = source.locationOffset.column - 1; - const body = whitespace(firstLineColumnOffset) + source.body; - - const lineIndex = location.line - 1; - const lineOffset = source.locationOffset.line - 1; - const lineNum = location.line + lineOffset; - - const columnOffset = location.line === 1 ? firstLineColumnOffset : 0; - const columnNum = location.column + columnOffset; - - const lines = body.split(/\r\n|[\n\r]/g); - return ( - `${source.name} (${lineNum}:${columnNum})\n` + - printPrefixedLines([ - // Lines specified like this: ["prefix", "string"], - [`${lineNum - 1}: `, lines[lineIndex - 1]], - [`${lineNum}: `, lines[lineIndex]], - ['', whitespace(columnNum - 1) + '^'], - [`${lineNum + 1}: `, lines[lineIndex + 1]], - ]) - ); -} - -function printPrefixedLines(lines: Array<[string, string]>): string { - const existingLines = lines.filter(([_, line]) => line !== undefined); - - let padLen = 0; - for (const [prefix] of existingLines) { - padLen = Math.max(padLen, prefix.length); - } - - return existingLines - .map(([prefix, line]) => lpad(padLen, prefix) + line) - .join('\n'); -} - -function whitespace(len: number): string { - return Array(len + 1).join(' '); -} - -function lpad(len: number, str: string): string { - return whitespace(len - str.length) + str; -} - -function getLocation(source: Source, position: number): SourceLocation { - const lineRegexp = /\r\n|[\n\r]/g; - let line = 1; - let column = position + 1; - let match; - while ((match = lineRegexp.exec(source.body)) && match.index < position) { - line += 1; - column = position + 1 - (match.index + match[0].length); - } - return {line, column}; -} - module.exports = { createCombinedError, createCompilerError, diff --git a/packages/relay-compiler/core/RelayFindGraphQLTags.js b/packages/relay-compiler/core/RelayFindGraphQLTags.js index 6bfac04cc6387..28748ace20b4c 100644 --- a/packages/relay-compiler/core/RelayFindGraphQLTags.js +++ b/packages/relay-compiler/core/RelayFindGraphQLTags.js @@ -23,14 +23,14 @@ import type { GraphQLTagFinder, } from '../language/RelayLanguagePluginInterface'; -const cache = new RelayCompilerCache('RelayFindGraphQLTags', 'v1'); +const cache = new RelayCompilerCache('RelayFindGraphQLTags', 'v2'); function memoizedFind( tagFinder: GraphQLTagFinder, text: string, baseDir: string, file: File, -): $ReadOnlyArray { +): $ReadOnlyArray { invariant( file.exists, 'RelayFindGraphQLTags: Called with non-existent file `%s`', @@ -46,11 +46,11 @@ function find( tagFinder: GraphQLTagFinder, text: string, absPath: string, -): $ReadOnlyArray { +): $ReadOnlyArray { const tags = tagFinder(text, absPath); const moduleName = getModuleName(absPath); tags.forEach(tag => validateTemplate(tag, moduleName, absPath)); - return tags.map(tag => tag.template); + return tags; } function validateTemplate( diff --git a/packages/relay-compiler/core/RelaySourceModuleParser.js b/packages/relay-compiler/core/RelaySourceModuleParser.js index 3171cd3dfbf50..d9df236bb712c 100644 --- a/packages/relay-compiler/core/RelaySourceModuleParser.js +++ b/packages/relay-compiler/core/RelaySourceModuleParser.js @@ -73,14 +73,18 @@ module.exports = ( const astDefinitions = []; const sources = []; - memoizedTagFinder(text, baseDir, file).forEach(template => { - const source = new GraphQL.Source(template, file.relPath); + memoizedTagFinder(text, baseDir, file).forEach(tag => { + const source = new GraphQL.Source( + tag.template, + path.join(path.relative(process.cwd(), baseDir), file.relPath), + tag.sourceLocationOffset, + ); const ast = parseGraphQL(source); invariant( ast.definitions.length, 'RelaySourceModuleParser: Expected GraphQL text to contain at least one ' + 'definition (fragment, mutation, query, subscription), got `%s`.', - template, + tag.template, ); sources.push(source.body); astDefinitions.push(...ast.definitions); diff --git a/packages/relay-compiler/core/__tests__/RelayFindGraphQLTags-test.js b/packages/relay-compiler/core/__tests__/RelayFindGraphQLTags-test.js index dfa790f091788..c6f9360503f77 100644 --- a/packages/relay-compiler/core/__tests__/RelayFindGraphQLTags-test.js +++ b/packages/relay-compiler/core/__tests__/RelayFindGraphQLTags-test.js @@ -15,7 +15,9 @@ const RelayFindGraphQLTags = require('../RelayFindGraphQLTags'); describe('RelayFindGraphQLTags', () => { function find(text, absPath: string = '/path/to/FindGraphQLTags.js') { - return RelayFindGraphQLTags.find(FindGraphQLTags.find, text, absPath); + return RelayFindGraphQLTags.find(FindGraphQLTags.find, text, absPath).map( + tag => tag.template, + ); } describe('query parsing', () => { diff --git a/packages/relay-compiler/core/__tests__/__snapshots__/RelayParser-test.js.snap b/packages/relay-compiler/core/__tests__/__snapshots__/RelayParser-test.js.snap index e4ba9021a408b..b5d3932b3fa82 100644 --- a/packages/relay-compiler/core/__tests__/__snapshots__/RelayParser-test.js.snap +++ b/packages/relay-compiler/core/__tests__/__snapshots__/RelayParser-test.js.snap @@ -16,12 +16,11 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Expected definition for variable '$size' to be an object with the shape: '{type: string, defaultValue?: mixed}. - GraphQL request (4:9) - 3: id: {type: "ID"} - 4: size: {type: "[Int]", defaultValu: [100]} # uh-oh, typo - ^ - 5: ) { - + GraphQL request:4:9 + 3 | id: {type: "ID"} + 4 | size: {type: "[Int]", defaultValu: [100]} # uh-oh, typo + | ^ + 5 | ) { `; exports[`RelayParser matches expected output: client-fields.graphql 1`] = ` @@ -932,12 +931,11 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Invalid directives @match found on FRAGMENT_DEFINITION. - GraphQL request (2:26) - 1: # expected-to-throw - 2: fragment Example on User @match(key: "Example"){ - ^ - 3: friends { - + GraphQL request:2:26 + 1 | # expected-to-throw + 2 | fragment Example on User @match(key: "Example"){ + | ^ + 3 | friends { `; exports[`RelayParser matches expected output: directive-module-match-on-query.invalid.graphql 1`] = ` @@ -955,18 +953,17 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Invalid directives @module, @match found on QUERY. - GraphQL request (2:27) - 1: # expected-to-throw - 2: query TestQuery($id: ID!) @module @match{ - ^ - 3: foo: node(id: $id) { - - GraphQL request (2:35) - 1: # expected-to-throw - 2: query TestQuery($id: ID!) @module @match{ - ^ - 3: foo: node(id: $id) { + GraphQL request:2:27 + 1 | # expected-to-throw + 2 | query TestQuery($id: ID!) @module @match{ + | ^ + 3 | foo: node(id: $id) { + GraphQL request:2:35 + 1 | # expected-to-throw + 2 | query TestQuery($id: ID!) @module @match{ + | ^ + 3 | foo: node(id: $id) { `; exports[`RelayParser matches expected output: directive-module-on-field.invalid.graphql 1`] = ` @@ -990,12 +987,11 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Invalid directives @module found on FIELD. - GraphQL request (6:24) - 5: node { - 6: profilePicture @module(preset: $preset) { - ^ - 7: uri - + GraphQL request:6:24 + 5 | node { + 6 | profilePicture @module(preset: $preset) { + | ^ + 7 | uri `; exports[`RelayParser matches expected output: enum-values.graphql 1`] = ` @@ -1178,28 +1174,25 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 3 error(s): - Expected a value matching type 'PhotoSize'. - GraphQL request (4:28) - 3: me { - 4: profilePicture(preset: "LARGE") { # error: string not enum - ^ - 5: uri - + GraphQL request:4:28 + 3 | me { + 4 | profilePicture(preset: "LARGE") { # error: string not enum + | ^ + 5 | uri - Expected a value matching type 'PhotoSize'. - GraphQL request (12:28) - 11: me { - 12: profilePicture(preset: 128) { # error: int not enum - ^ - 13: uri - + GraphQL request:12:28 + 11 | me { + 12 | profilePicture(preset: 128) { # error: int not enum + | ^ + 13 | uri - Expected a value matching type 'PhotoSize'. - GraphQL request (20:28) - 19: me { - 20: profilePicture(preset: [LARGE]) { # error: list of enum, not enum - ^ - 21: uri - + GraphQL request:20:28 + 19 | me { + 20 | profilePicture(preset: [LARGE]) { # error: list of enum, not enum + | ^ + 21 | uri `; exports[`RelayParser matches expected output: field-arguments.graphql 1`] = ` @@ -2786,18 +2779,17 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Variable '$environment' was defined as type 'Environment!' but used in a location expecting the type '[Environment!]!' - GraphQL request (9:53) - 8: - 9: fragment ChildFragment on User @argumentDefinitions(environment: {type: "Environment!"}){ - ^ - 10: # variables of a non-list type cannot flow into list types, - - GraphQL request (12:26) - 11: # the singular -> list promotion only works for literal values - 12: checkins(environments: $environment) { # expected error - ^ - 13: query + GraphQL request:9:53 + 8 | + 9 | fragment ChildFragment on User @argumentDefinitions(environment: {type: "Environment!"}){ + | ^ + 10 | # variables of a non-list type cannot flow into list types, + GraphQL request:12:26 + 11 | # the singular -> list promotion only works for literal values + 12 | checkins(environments: $environment) { # expected error + | ^ + 13 | query `; exports[`RelayParser matches expected output: fragment-with-literal-enum-list-arguments.graphql 1`] = ` @@ -3848,18 +3840,17 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Literal @arguments values are only supported when the argument is defined with @argumentDefinitions. Check the definition of fragment 'ChildFragment'. - GraphQL request (3:44) - 2: fragment ParentFragment on User { - 3: ...ChildFragment @arguments(pictureSize: 42) # error: $pictureSize not defined - ^ - 4: } - - GraphQL request (6:1) - 5: - 6: fragment ChildFragment on User { - ^ - 7: profilePicture(size: $pictureSize) { + GraphQL request:3:44 + 2 | fragment ParentFragment on User { + 3 | ...ChildFragment @arguments(pictureSize: 42) # error: $pictureSize not defined + | ^ + 4 | } + GraphQL request:6:1 + 5 | + 6 | fragment ChildFragment on User { + | ^ + 7 | profilePicture(size: $pictureSize) { `; exports[`RelayParser matches expected output: fragment-with-undefined-variable-arguments.invalid.graphql 1`] = ` @@ -3881,18 +3872,17 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Variable @arguments values are only supported when the argument is defined with @argumentDefinitions. Check the definition of fragment 'ChildFragment'. - GraphQL request (3:44) - 2: fragment ParentFragment on User { - 3: ...ChildFragment @arguments(pictureSize: $querySize) # error: $pictureSize not defined - ^ - 4: } - - GraphQL request (6:1) - 5: - 6: fragment ChildFragment on User { - ^ - 7: profilePicture(size: $pictureSize) { + GraphQL request:3:44 + 2 | fragment ParentFragment on User { + 3 | ...ChildFragment @arguments(pictureSize: $querySize) # error: $pictureSize not defined + | ^ + 4 | } + GraphQL request:6:1 + 5 | + 6 | fragment ChildFragment on User { + | ^ + 7 | profilePicture(size: $pictureSize) { `; exports[`RelayParser matches expected output: fragment-with-unnecessary-unchecked-arguments.invalid.graphql 1`] = ` @@ -3921,12 +3911,11 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Invalid use of @uncheckedArguments_DEPRECATED: all arguments are defined, use @arguments instead. - GraphQL request (12:10) - 11: } - 12: ...Foo @uncheckedArguments_DEPRECATED(localId: $id) - ^ - 13: } - + GraphQL request:12:10 + 11 | } + 12 | ...Foo @uncheckedArguments_DEPRECATED(localId: $id) + | ^ + 13 | } `; exports[`RelayParser matches expected output: inline-untyped-fragment.graphql 1`] = ` @@ -5054,28 +5043,25 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 3 error(s): - Expected a value matching type 'String'. - GraphQL request (4:10) - 3: route(waypoints: [{ - 4: lat: 0.0 # error: float not string - ^ - 5: lon: "0.0" - + GraphQL request:4:10 + 3 | route(waypoints: [{ + 4 | lat: 0.0 # error: float not string + | ^ + 5 | lon: "0.0" - Expected a value matching type 'WayPoint!'. - GraphQL request (14:21) - 13: query LiteralListArgumentQuery2 { - 14: route(waypoints: ["waypoint"]) { # error: string not input object - ^ - 15: steps { - + GraphQL request:14:21 + 13 | query LiteralListArgumentQuery2 { + 14 | route(waypoints: ["waypoint"]) { # error: string not input object + | ^ + 15 | steps { - Expected a value matching type 'WayPoint!'. - GraphQL request (22:20) - 21: query LiteralListArgumentQuery3 { - 22: route(waypoints: "waypoint") { # error: string not list - ^ - 23: steps { - + GraphQL request:22:20 + 21 | query LiteralListArgumentQuery3 { + 22 | route(waypoints: "waypoint") { # error: string not list + | ^ + 23 | steps { `; exports[`RelayParser matches expected output: literal-object-argument.graphql 1`] = ` @@ -5234,28 +5220,25 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 3 error(s): - Uknown field 'unknownField' on type 'CheckinSearchInput'. - GraphQL request (4:5) - 3: checkinSearchQuery(query: { - 4: unknownField: "Facebook" # error: unknown field - ^ - 5: }) { - + GraphQL request:4:5 + 3 | checkinSearchQuery(query: { + 4 | unknownField: "Facebook" # error: unknown field + | ^ + 5 | }) { - Expected a value matching type 'String'. - GraphQL request (12:12) - 11: checkinSearchQuery(query: { - 12: query: FACEBOOK # error: enum not string - ^ - 13: }) { - + GraphQL request:12:12 + 11 | checkinSearchQuery(query: { + 12 | query: FACEBOOK # error: enum not string + | ^ + 13 | }) { - Expected a value matching type 'CheckinSearchInput'. - GraphQL request (19:29) - 18: query LiteralObjectArgument3 { - 19: checkinSearchQuery(query: FACEBOOK) { # error: enum not object - ^ - 20: query - + GraphQL request:19:29 + 18 | query LiteralObjectArgument3 { + 19 | checkinSearchQuery(query: FACEBOOK) { # error: enum not object + | ^ + 20 | query `; exports[`RelayParser matches expected output: null-values.graphql 1`] = ` @@ -5396,12 +5379,11 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Expected a value matching type 'ID!'. - GraphQL request (3:24) - 2: query NullValuesQuery { - 3: node_id_required(id: null) { - ^ - 4: id - + GraphQL request:3:24 + 2 | query NullValuesQuery { + 3 | node_id_required(id: null) { + | ^ + 4 | id `; exports[`RelayParser matches expected output: object-argument.graphql 1`] = ` @@ -5870,40 +5852,37 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Unknown type: 'UnknownType'. - GraphQL request (2:22) - 1: # expected-to-throw - 2: query TestQuery($id: UnknownType) { - ^ - 3: node(id: "someid") { - + GraphQL request:2:22 + 1 | # expected-to-throw + 2 | query TestQuery($id: UnknownType) { + | ^ + 3 | node(id: "someid") { `; exports[`RelayParser should error on fragment spread arguments with literal out of bounds values 1`] = ` "RelayParser: Encountered 1 error(s): - Expected a value matching type 'Int'. - GraphQL request (4:38) - 3: # Number.MAX_SAFE_INTEGER is 9007199254740991 - 4: ...TestChild @arguments(foo: 10000000000000000) - ^ - 5: } - " + GraphQL request:4:38 + 3 | # Number.MAX_SAFE_INTEGER is 9007199254740991 + 4 | ...TestChild @arguments(foo: 10000000000000000) + | ^ + 5 | }" `; exports[`RelayParser should error when parsing fragment that references undeclared variables are used with differing types 1`] = ` "RelayParser: Encountered 1 error(s): - Variable '$id' was used in locations expecting the conflicting types 'ID' and 'Int'. - GraphQL request (2:14) - 1: fragment TestFragment on Query { - 2: node(id: $id) { - ^ - 3: id + GraphQL request:2:14 + 1 | fragment TestFragment on Query { + 2 | node(id: $id) { + | ^ + 3 | id - GraphQL request (5:18) - 4: } - 5: task(number: $id) { - ^ - 6: title - " + GraphQL request:5:18 + 4 | } + 5 | task(number: $id) { + | ^ + 6 | title" `; diff --git a/packages/relay-compiler/core/__tests__/__snapshots__/RelayPrinter-test.js.snap b/packages/relay-compiler/core/__tests__/__snapshots__/RelayPrinter-test.js.snap index 951c664e1d939..466d17dd18460 100644 --- a/packages/relay-compiler/core/__tests__/__snapshots__/RelayPrinter-test.js.snap +++ b/packages/relay-compiler/core/__tests__/__snapshots__/RelayPrinter-test.js.snap @@ -161,12 +161,11 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Expected a value matching type 'Environment!'. - GraphQL request (3:26) - 2: fragment UserFragment on User { - 3: checkins(environments: "WEB") { - ^ - 4: __typename - + GraphQL request:3:26 + 2 | fragment UserFragment on User { + 3 | checkins(environments: "WEB") { + | ^ + 4 | __typename `; exports[`GraphQLIRPrinter matches expected output: string-enum-fragment-arg.graphql 1`] = ` @@ -205,10 +204,9 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Expected a value matching type 'Environment!'. - GraphQL request (3:26) - 2: fragment UserFragment on User { - 3: checkins(environments: UNKNOWN_ENUM_VALUE) { - ^ - 4: __typename - + GraphQL request:3:26 + 2 | fragment UserFragment on User { + 3 | checkins(environments: UNKNOWN_ENUM_VALUE) { + | ^ + 4 | __typename `; diff --git a/packages/relay-compiler/handlers/connection/__tests__/__snapshots__/RelayConnectionTransform-test.js.snap b/packages/relay-compiler/handlers/connection/__tests__/__snapshots__/RelayConnectionTransform-test.js.snap index ec3b83b9183d3..690fa766459c8 100644 --- a/packages/relay-compiler/handlers/connection/__tests__/__snapshots__/RelayConnectionTransform-test.js.snap +++ b/packages/relay-compiler/handlers/connection/__tests__/__snapshots__/RelayConnectionTransform-test.js.snap @@ -546,11 +546,11 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Expected field 'comments' to have a 'first' or 'last' argument. - Source: GraphQL request (8:7) - 7: ... on Story { - 8: comments @connection(key: "NodeQuery_comments") { - ^ - 9: edges { + Source: GraphQL request:8:7 + 7 | ... on Story { + 8 | comments @connection(key: "NodeQuery_comments") { + | ^ + 9 | edges { `; @@ -872,11 +872,11 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Expected the key argument to @connection to be of form _comments, got 'invalid'. For a detailed explanation, check out https://relay.dev/docs/en/pagination-container#connection - Source: GraphQL request (8:44) - 7: ... on Story { - 8: comments(first: 10) @connection(key: "invalid") { - ^ - 9: edges { + Source: GraphQL request:8:44 + 7 | ... on Story { + 8 | comments(first: 10) @connection(key: "invalid") { + | ^ + 9 | edges { `; @@ -906,12 +906,11 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Expected a value matching type 'String!'. - GraphQL request (8:44) - 7: ... on Story { - 8: comments(first: 10) @connection(key: 10) { - ^ - 9: edges { - + GraphQL request:8:44 + 7 | ... on Story { + 8 | comments(first: 10) @connection(key: 10) { + | ^ + 9 | edges { `; exports[`RelayConnectionTransform matches expected output: invalid-connection-with-custom-handler.graphql 1`] = ` @@ -949,12 +948,11 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Expected a value matching type 'String'. - GraphQL request (8:75) - 7: ... on Story { - 8: comments(first: 10) @connection(key: "NodeQuery_comments", handler: 10) { - ^ - 9: edges { - + GraphQL request:8:75 + 7 | ... on Story { + 8 | comments(first: 10) @connection(key: "NodeQuery_comments", handler: 10) { + | ^ + 9 | edges { `; exports[`RelayConnectionTransform matches expected output: invalid-type.graphql 1`] = ` @@ -979,11 +977,11 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - @connection used on invalid field 'actors'. Expected the return type to be a non-plural interface or object, got '[Actor]'. - Source: GraphQL request (8:7) - 7: ... on Story { - 8: actors @connection { - ^ - 9: name + Source: GraphQL request:8:7 + 7 | ... on Story { + 8 | actors @connection { + | ^ + 9 | name `; @@ -1186,11 +1184,11 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - @stream_connection does not support aliasing the 'edges' field. - Source: GraphQL request (14:9) - 13: ) { - 14: commentEdges: edges { - ^ - 15: node { + Source: GraphQL request:14:9 + 13 | ) { + 14 | commentEdges: edges { + | ^ + 15 | node { `; @@ -1230,10 +1228,10 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - @stream_connection does not support aliasing the 'pageInfo' field. - Source: GraphQL request (21:9) - 20: } - 21: commentPageInfo: pageInfo { - ^ - 22: hasNextPage + Source: GraphQL request:21:9 + 20 | } + 21 | commentPageInfo: pageInfo { + | ^ + 22 | hasNextPage `; diff --git a/packages/relay-compiler/package.json b/packages/relay-compiler/package.json index aefc6a65bccda..ea45d669d3f86 100644 --- a/packages/relay-compiler/package.json +++ b/packages/relay-compiler/package.json @@ -34,6 +34,6 @@ "yargs": "^9.0.0" }, "peerDependencies": { - "graphql": "^14.2.0" + "graphql": "^14.4.0" } } diff --git a/packages/relay-compiler/transforms/__tests__/__snapshots__/FlattenTransform-test.js.snap b/packages/relay-compiler/transforms/__tests__/__snapshots__/FlattenTransform-test.js.snap index 870cd8232675c..99cee4483185e 100644 --- a/packages/relay-compiler/transforms/__tests__/__snapshots__/FlattenTransform-test.js.snap +++ b/packages/relay-compiler/transforms/__tests__/__snapshots__/FlattenTransform-test.js.snap @@ -33,17 +33,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Expected all fields on the same parent with the name or alias 'friendsAlias' to have the same name and arguments. - Source: GraphQL request (14:9) - 13: ... on User { - 14: friendsAlias: friends(first: 10) { - ^ - 15: edges { + Source: GraphQL request:14:9 + 13 | ... on User { + 14 | friendsAlias: friends(first: 10) { + | ^ + 15 | edges { - Source: GraphQL request (9:9) - 8: ... on User { - 9: friendsAlias: friends(first: 5) { - ^ - 10: count + Source: GraphQL request:9:9 + 8 | ... on User { + 9 | friendsAlias: friends(first: 5) { + | ^ + 10 | count `; @@ -80,17 +80,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Expected all fields on the same parent with the name or alias 'friends' to have the same name and arguments. - Source: GraphQL request (14:9) - 13: ... on User { - 14: friends(first: 10) { - ^ - 15: edges { + Source: GraphQL request:14:9 + 13 | ... on User { + 14 | friends(first: 10) { + | ^ + 15 | edges { - Source: GraphQL request (9:9) - 8: ... on User { - 9: friends(first: 5) { - ^ - 10: count + Source: GraphQL request:9:9 + 8 | ... on User { + 9 | friends(first: 5) { + | ^ + 10 | count `; @@ -455,17 +455,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Expected all fields on the same parent with the name or alias 'nameRenderer' to have the same name and arguments. - Source: GraphQL request (11:5) - 10: # conflicts with above: same alias but different types are matched - 11: nameRenderer @match { - ^ - 12: ...MarkdownUserNameRenderer_name + Source: GraphQL request:11:5 + 10 | # conflicts with above: same alias but different types are matched + 11 | nameRenderer @match { + | ^ + 12 | ...MarkdownUserNameRenderer_name - Source: GraphQL request (4:3) - 3: id - 4: nameRenderer @match { - ^ - 5: ...PlainUserNameRenderer_name @module(name: "PlainUserNameRenderer.react") + Source: GraphQL request:4:3 + 3 | id + 4 | nameRenderer @match { + | ^ + 5 | ...PlainUserNameRenderer_name @module(name: "PlainUserNameRenderer.react") `; @@ -509,17 +509,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Found conflicting @module selections: use a unique alias on the parent fields. - Source: GraphQL request (12:37) - 11: nameRenderer @match { - 12: ...PlainUserNameRenderer_name @module(name: "OtherPlainUserNameRenderer.react") - ^ - 13: ...MarkdownUserNameRenderer_name + Source: GraphQL request:12:37 + 11 | nameRenderer @match { + 12 | ...PlainUserNameRenderer_name @module(name: "OtherPlainUserNameRenderer.react") + | ^ + 13 | ...MarkdownUserNameRenderer_name - Source: GraphQL request (5:35) - 4: nameRenderer @match { - 5: ...PlainUserNameRenderer_name @module(name: "PlainUserNameRenderer.react") - ^ - 6: ...MarkdownUserNameRenderer_name + Source: GraphQL request:5:35 + 4 | nameRenderer @match { + 5 | ...PlainUserNameRenderer_name @module(name: "PlainUserNameRenderer.react") + | ^ + 6 | ...MarkdownUserNameRenderer_name `; diff --git a/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayApplyFragmentArgumentTransform-test.js.snap b/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayApplyFragmentArgumentTransform-test.js.snap index 6a7728af2f080..c180ad9b0af3b 100644 --- a/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayApplyFragmentArgumentTransform-test.js.snap +++ b/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayApplyFragmentArgumentTransform-test.js.snap @@ -303,23 +303,23 @@ THROWN EXCEPTION: Error: Found a circular reference from fragment 'Profile'. -Source: GraphQL request (2:1) -1: # expected-to-throw -2: query TestQuery( - ^ -3: $id: ID! - -Source: GraphQL request (8:5) -7: id -8: ...Profile - ^ -9: } - -Source: GraphQL request (21:9) -20: node { -21: ...Profile - ^ -22: } +Source: GraphQL request:2:1 +1 | # expected-to-throw +2 | query TestQuery( + | ^ +3 | $id: ID! + +Source: GraphQL request:8:5 +7 | id +8 | ...Profile + | ^ +9 | } + +Source: GraphQL request:21:9 +20 | node { +21 | ...Profile + | ^ +22 | } `; @@ -361,12 +361,11 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Query 'TestQuery' references undefined variables. - GraphQL request (9:70) - 8: id - 9: ...Profile @arguments(pictureSize: $pictureSize, includeFriends: $includeFriends2) - ^ - 10: } - + GraphQL request:9:70 + 8 | id + 9 | ...Profile @arguments(pictureSize: $pictureSize, includeFriends: $includeFriends2) + | ^ + 10 | } `; exports[`RelayApplyFragmentArgumentTransform matches expected output: uses-defaults-for-literal-null-arguments.graphql 1`] = ` diff --git a/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayDeferStreamTransform-test.js.snap b/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayDeferStreamTransform-test.js.snap index 321d9ee44bd2e..c0fed37c9a2b6 100644 --- a/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayDeferStreamTransform-test.js.snap +++ b/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayDeferStreamTransform-test.js.snap @@ -165,17 +165,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Invalid use of @defer, the provided label is not unique. Specify a unique 'label' as a literal string. - Source: GraphQL request (13:35) - 12: ...DeferredFragment @defer(label: "deferred") - 13: ...OtherDeferredFragment @defer(label: "deferred") - ^ - 14: } + Source: GraphQL request:13:35 + 12 | ...DeferredFragment @defer(label: "deferred") + 13 | ...OtherDeferredFragment @defer(label: "deferred") + | ^ + 14 | } - Source: GraphQL request (12:30) - 11: emailAddresses - 12: ...DeferredFragment @defer(label: "deferred") - ^ - 13: ...OtherDeferredFragment @defer(label: "deferred") + Source: GraphQL request:12:30 + 11 | emailAddresses + 12 | ...DeferredFragment @defer(label: "deferred") + | ^ + 13 | ...OtherDeferredFragment @defer(label: "deferred") `; @@ -360,17 +360,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Invalid use of @stream, the provided label is not unique. Specify a unique 'label' as a literal string. - Source: GraphQL request (15:29) - 14: otherActors: actors - 15: @stream(initial_count: 1, label: "actors") { # invalid: duplicate label - ^ - 16: name + Source: GraphQL request:15:29 + 14 | otherActors: actors + 15 | @stream(initial_count: 1, label: "actors") { # invalid: duplicate label + | ^ + 16 | name - Source: GraphQL request (11:36) - 10: id - 11: actors @stream(initial_count: 1, label: "actors") { - ^ - 12: name + Source: GraphQL request:11:36 + 10 | id + 11 | actors @stream(initial_count: 1, label: "actors") { + | ^ + 12 | name `; @@ -469,11 +469,11 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Invalid use of @stream, the 'initial_count' argument is required. - Source: GraphQL request (11:10) - 10: id - 11: actors @stream(label: "StreamedActorsLabel") { # invalid: missing initial_count - ^ - 12: name + Source: GraphQL request:11:10 + 10 | id + 11 | actors @stream(label: "StreamedActorsLabel") { # invalid: missing initial_count + | ^ + 12 | name `; @@ -535,11 +535,11 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Expected the 'label' value to @stream to be a string literal if provided. - Source: GraphQL request (11:43) - 10: id - 11: actors @stream(initial_count: 1, label: $label) { - ^ - 12: name + Source: GraphQL request:11:43 + 10 | id + 11 | actors @stream(initial_count: 1, label: $label) { + | ^ + 12 | name `; @@ -570,11 +570,11 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Expected the 'label' value to @defer to be a string literal if provided. - Source: GraphQL request (12:37) - 11: emailAddresses - 12: ...DeferredFragment @defer(label: $label) - ^ - 13: } + Source: GraphQL request:12:37 + 11 | emailAddresses + 12 | ...DeferredFragment @defer(label: $label) + | ^ + 13 | } `; @@ -680,17 +680,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Invalid use of @defer, could not generate a default label that is unique. Specify a unique 'label' as a literal string. - Source: GraphQL request (16:15) - 15: } - 16: ... on User @defer { # invalid: duplicate label - ^ - 17: name + Source: GraphQL request:16:15 + 15 | } + 16 | ... on User @defer { # invalid: duplicate label + | ^ + 17 | name - Source: GraphQL request (12:15) - 11: emailAddresses - 12: ... on User @defer { - ^ - 13: id + Source: GraphQL request:12:15 + 11 | emailAddresses + 12 | ... on User @defer { + | ^ + 13 | id `; @@ -756,11 +756,11 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Expected the 'label' value to @defer to be a string literal if provided. - Source: GraphQL request (12:29) - 11: emailAddresses - 12: ... on User @defer(label: $label) { - ^ - 13: id + Source: GraphQL request:12:29 + 11 | emailAddresses + 12 | ... on User @defer(label: $label) { + | ^ + 13 | id `; diff --git a/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayMaskTransform-test.js.snap b/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayMaskTransform-test.js.snap index 916394b20de68..818bfa7690951 100644 --- a/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayMaskTransform-test.js.snap +++ b/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayMaskTransform-test.js.snap @@ -92,17 +92,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Cannot combine variables with incompatible types Int and ID when applying @relay(unmask: true). - Source: GraphQL request (14:16) - 13: fragment StringFragment on Query { - 14: task(number: $id) { - ^ - 15: title + Source: GraphQL request:14:16 + 13 | fragment StringFragment on Query { + 14 | task(number: $id) { + | ^ + 15 | title - Source: GraphQL request (8:12) - 7: fragment NullableIDFragment on Query { - 8: node(id: $id) { - ^ - 9: id + Source: GraphQL request:8:12 + 7 | fragment NullableIDFragment on Query { + 8 | node(id: $id) { + | ^ + 9 | id `; @@ -132,17 +132,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Cannot combine variables with incompatible types [ID!] and ID when applying @relay(unmask: true). - Source: GraphQL request (14:14) - 13: fragment NullableIDListFragment on Query { - 14: nodes(ids: $id) { - ^ - 15: id + Source: GraphQL request:14:14 + 13 | fragment NullableIDListFragment on Query { + 14 | nodes(ids: $id) { + | ^ + 15 | id - Source: GraphQL request (8:12) - 7: fragment NullableIDFragment on Query { - 8: node(id: $id) { - ^ - 9: id + Source: GraphQL request:8:12 + 7 | fragment NullableIDFragment on Query { + 8 | node(id: $id) { + | ^ + 9 | id `; @@ -167,17 +167,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Cannot combine global and local variables when applying @relay(unmask: true). - Source: GraphQL request (3:3) - 2: fragment ParentQuery on Query @argumentDefinitions( - 3: id: {type: "ID!"} - ^ - 4: ) { + Source: GraphQL request:3:3 + 2 | fragment ParentQuery on Query @argumentDefinitions( + 3 | id: {type: "ID!"} + | ^ + 4 | ) { - Source: GraphQL request (9:24) - 8: fragment NonNullIDFragment on Query { - 9: node_id_required(id: $id) { - ^ - 10: id + Source: GraphQL request:9:24 + 8 | fragment NonNullIDFragment on Query { + 9 | node_id_required(id: $id) { + | ^ + 10 | id `; diff --git a/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayMatchTransform-test.js.snap b/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayMatchTransform-test.js.snap index 316be984393cc..46bdae5099cbc 100644 --- a/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayMatchTransform-test.js.snap +++ b/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayMatchTransform-test.js.snap @@ -18,11 +18,11 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Direct use of the 'js' field is not allowed, use @match/@module instead. - Source: GraphQL request (6:7) - 5: ... on PlainUserNameRenderer { - 6: js(module: "PlainUserNameRenderer.react") - ^ - 7: } + Source: GraphQL request:6:7 + 5 | ... on PlainUserNameRenderer { + 6 | js(module: "PlainUserNameRenderer.react") + | ^ + 7 | } `; @@ -54,17 +54,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Invalid @match selection: selections must match against concrete variants/implementors of type 'UserNameRenderer'. Got 'User', expected one of 'PlainUserNameRenderer', 'MarkdownUserNameRenderer', 'CustomNameRenderer', etc. - Source: GraphQL request (6:18) - 5: ...PlainUserNameRenderer_name @module(name: "PlainUserNameRenderer.react") - 6: ...User_user @module(name: "User.react") - ^ - 7: } + Source: GraphQL request:6:18 + 5 | ...PlainUserNameRenderer_name @module(name: "PlainUserNameRenderer.react") + 6 | ...User_user @module(name: "User.react") + | ^ + 7 | } - Source: GraphQL request (17:1) - 16: - 17: fragment User_user on User { - ^ - 18: __typename + Source: GraphQL request:17:1 + 16 | + 17 | fragment User_user on User { + | ^ + 18 | __typename `; @@ -82,12 +82,11 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Expected at least one selection for non-scalar field 'nameRenderer' on type 'UserNameRenderer'. - GraphQL request (4:3) - 3: id - 4: nameRenderer @match - ^ - 5: } - + GraphQL request:4:3 + 3 | id + 4 | nameRenderer @match + | ^ + 5 | } `; exports[`RelayMatchTransform matches expected output: invalid-non-empty-selections.graphql 1`] = ` @@ -123,11 +122,11 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Invalid @match selection: all selections should be fragment spreads with @module. - Source: GraphQL request (5:5) - 4: nameRenderer @match { - 5: __typename - ^ - 6: ...PlainUserNameRenderer_name @module(name: "PlainUserNameRenderer.react") + Source: GraphQL request:5:5 + 4 | nameRenderer @match { + 5 | __typename + | ^ + 6 | ...PlainUserNameRenderer_name @module(name: "PlainUserNameRenderer.react") `; @@ -228,11 +227,11 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - @module does not support @arguments. - Source: GraphQL request (7:66) - 6: ...MarkdownUserNameRenderer_name - 7: @module(name: "MarkdownUserNameRenderer.react") @arguments(cond: true) - ^ - 8: } + Source: GraphQL request:7:66 + 6 | ...MarkdownUserNameRenderer_name + 7 | @module(name: "MarkdownUserNameRenderer.react") @arguments(cond: true) + | ^ + 8 | } `; @@ -269,11 +268,11 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Invalid @match selection: the 'supported' argument is automatically added and cannot be supplied explicitly. - Source: GraphQL request (4:16) - 3: id - 4: nameRenderer(supported: ["PlainUserNameRenderer", "MarkdownUserNameRenderer"]) - ^ - 5: @match { + Source: GraphQL request:4:16 + 3 | id + 4 | nameRenderer(supported: ["PlainUserNameRenderer", "MarkdownUserNameRenderer"]) + | ^ + 5 | @match { `; diff --git a/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayRefetchableFragmentTransform-test.js.snap b/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayRefetchableFragmentTransform-test.js.snap index 79de3a126ac72..53d006b9109bf 100644 --- a/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayRefetchableFragmentTransform-test.js.snap +++ b/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayRefetchableFragmentTransform-test.js.snap @@ -55,11 +55,11 @@ THROWN EXCEPTION: Error: RelayRefetchableFragmentTransform: Encountered 1 error(s): - Invalid use of @refetchable on fragment 'UserName', only fragments on the Query type, Viewer type, Node type, or types implementing Node are supported. - Source: GraphQL request (2:1) - 1: # expected-to-throw - 2: fragment UserName on UserNameRenderable @refetchable(queryName: "RefetchableFragmentQuery") { - ^ - 3: name + Source: GraphQL request:2:1 + 1 | # expected-to-throw + 2 | fragment UserName on UserNameRenderable @refetchable(queryName: "RefetchableFragmentQuery") { + | ^ + 3 | name `; @@ -703,17 +703,17 @@ THROWN EXCEPTION: Error: RelayRefetchableFragmentTransform: Encountered 1 error(s): - Invalid use of @refetchable with @connection in fragment 'PaginationFragment', refetchable connections must use variables for the after and first arguments. - Source: GraphQL request (10:5) - 9: name - 10: friends(after: $cursor, first: 10) - ^ - 11: @connection(key: "PaginationFragment_friends") { + Source: GraphQL request:10:5 + 9 | name + 10 | friends(after: $cursor, first: 10) + | ^ + 11 | @connection(key: "PaginationFragment_friends") { - Source: GraphQL request (10:36) - 9: name - 10: friends(after: $cursor, first: 10) - ^ - 11: @connection(key: "PaginationFragment_friends") { + Source: GraphQL request:10:36 + 9 | name + 10 | friends(after: $cursor, first: 10) + | ^ + 11 | @connection(key: "PaginationFragment_friends") { `; @@ -745,17 +745,17 @@ THROWN EXCEPTION: Error: RelayRefetchableFragmentTransform: Encountered 1 error(s): - Invalid use of @refetchable with @connection in fragment 'PaginationFragment', refetchable connections must use variables for the after and first arguments. - Source: GraphQL request (10:5) - 9: name - 10: friends(after: "", first: $count) - ^ - 11: @connection(key: "PaginationFragment_friends") { + Source: GraphQL request:10:5 + 9 | name + 10 | friends(after: "", first: $count) + | ^ + 11 | @connection(key: "PaginationFragment_friends") { - Source: GraphQL request (10:20) - 9: name - 10: friends(after: "", first: $count) - ^ - 11: @connection(key: "PaginationFragment_friends") { + Source: GraphQL request:10:20 + 9 | name + 10 | friends(after: "", first: $count) + | ^ + 11 | @connection(key: "PaginationFragment_friends") { `; @@ -794,17 +794,17 @@ THROWN EXCEPTION: Error: RelayRefetchableFragmentTransform: Encountered 1 error(s): - Invalid use of @refetchable with @connection in fragment 'PaginationFragment', refetchable connections cannot appear inside plural fields. - Source: GraphQL request (14:11) - 13: node { - 14: friends(after: $cursor, first: $count) - ^ - 15: @connection(key: "PaginationFragment_friends") { + Source: GraphQL request:14:11 + 13 | node { + 14 | friends(after: $cursor, first: $count) + | ^ + 15 | @connection(key: "PaginationFragment_friends") { - Source: GraphQL request (12:7) - 11: friends(first: 1) { - 12: edges { - ^ - 13: node { + Source: GraphQL request:12:7 + 11 | friends(first: 1) { + 12 | edges { + | ^ + 13 | node { `; diff --git a/packages/relay-compiler/validations/__tests__/__snapshots__/validateRelayRequiredArguments-test.js.snap b/packages/relay-compiler/validations/__tests__/__snapshots__/validateRelayRequiredArguments-test.js.snap index dc3fd4ad47ec7..e867a2375adc8 100644 --- a/packages/relay-compiler/validations/__tests__/__snapshots__/validateRelayRequiredArguments-test.js.snap +++ b/packages/relay-compiler/validations/__tests__/__snapshots__/validateRelayRequiredArguments-test.js.snap @@ -107,17 +107,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Required argument 'level: Int!' is missing on 'customDirective' in 'ViewerQuery'. - Source: GraphQL request (5:10) - 4: node { - 5: body @customDirective { - ^ - 6: text + Source: GraphQL request:5:10 + 4 | node { + 5 | body @customDirective { + | ^ + 6 | text - Source: GraphQL request (3:1) - 2: - 3: query ViewerQuery { - ^ - 4: node { + Source: GraphQL request:3:1 + 2 | + 3 | query ViewerQuery { + | ^ + 4 | node { `; @@ -138,17 +138,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Required argument 'capitalize: Boolean!' is missing on 'nameWithArgs' in 'TestQuery'. - Source: GraphQL request (5:7) - 4: hometown{ - 5: nameWithArgs - ^ - 6: } + Source: GraphQL request:5:7 + 4 | hometown{ + 5 | nameWithArgs + | ^ + 6 | } - Source: GraphQL request (2:1) - 1: # expected-to-throw - 2: query TestQuery { - ^ - 3: node { + Source: GraphQL request:2:1 + 1 | # expected-to-throw + 2 | query TestQuery { + | ^ + 3 | node { `; @@ -177,17 +177,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Required argument 'supported: [String!]!' is missing on 'commentBody' in 'SomeComment'. - Source: GraphQL request (3:3) - 2: fragment SomeComment on Comment { - 3: commentBody { - ^ - 4: ... on PlainCommentBody { + Source: GraphQL request:3:3 + 2 | fragment SomeComment on Comment { + 3 | commentBody { + | ^ + 4 | ... on PlainCommentBody { - Source: GraphQL request (2:1) - 1: # expected-to-throw - 2: fragment SomeComment on Comment { - ^ - 3: commentBody { + Source: GraphQL request:2:1 + 1 | # expected-to-throw + 2 | fragment SomeComment on Comment { + | ^ + 3 | commentBody { `; @@ -214,17 +214,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Required argument 'supported: [String!]!' is missing on 'commentBody' in 'ViewerQuery'. - Source: GraphQL request (5:7) - 4: ... on Comment { - 5: commentBody { - ^ - 6: ... on PlainCommentBody { + Source: GraphQL request:5:7 + 4 | ... on Comment { + 5 | commentBody { + | ^ + 6 | ... on PlainCommentBody { - Source: GraphQL request (2:1) - 1: # expected-to-throw - 2: query ViewerQuery { - ^ - 3: node { + Source: GraphQL request:2:1 + 1 | # expected-to-throw + 2 | query ViewerQuery { + | ^ + 3 | node { `; @@ -285,10 +285,9 @@ THROWN EXCEPTION: Error: RelayParser: Encountered 1 error(s): - Unknown field 'commentBody' on type 'Node'. - GraphQL request (4:5) - 3: node { - 4: commentBody { - ^ - 5: ... on PlainCommentBody { - + GraphQL request:4:5 + 3 | node { + 4 | commentBody { + | ^ + 5 | ... on PlainCommentBody { `; diff --git a/packages/relay-compiler/validations/__tests__/__snapshots__/validateRelayServerOnlyDirectives-test.js.snap b/packages/relay-compiler/validations/__tests__/__snapshots__/validateRelayServerOnlyDirectives-test.js.snap index ac2adcd35a8b4..d0f88b3b4eba7 100644 --- a/packages/relay-compiler/validations/__tests__/__snapshots__/validateRelayServerOnlyDirectives-test.js.snap +++ b/packages/relay-compiler/validations/__tests__/__snapshots__/validateRelayServerOnlyDirectives-test.js.snap @@ -59,17 +59,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Unexpected directive: @defer. This directive can only be used on fields/fragments that are fetched from the server schema, but it is used inside a client-only selection. - Source (derived): GraphQL request (12:23) - 11: emailAddresses - 12: ...DeferredFragment @defer(label: "DeferredFragmentLabel") - ^ - 13: } + Source (derived): GraphQL request:12:23 + 11 | emailAddresses + 12 | ...DeferredFragment @defer(label: "DeferredFragmentLabel") + | ^ + 13 | } - Source (derived): GraphQL request (12:3) - 11: emailAddresses - 12: ...DeferredFragment @defer(label: "DeferredFragmentLabel") - ^ - 13: } + Source (derived): GraphQL request:12:3 + 11 | emailAddresses + 12 | ...DeferredFragment @defer(label: "DeferredFragmentLabel") + | ^ + 13 | } `; @@ -97,17 +97,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Unexpected directive: @defer. This directive can only be used on fields/fragments that are fetched from the server schema, but it is used inside a client-only selection. - Source (derived): GraphQL request (5:21) - 4: id - 5: ...UserFragment @defer(label: "DeferredFragmentLabel") - ^ - 6: } + Source (derived): GraphQL request:5:21 + 4 | id + 5 | ...UserFragment @defer(label: "DeferredFragmentLabel") + | ^ + 6 | } - Source: GraphQL request (10:3) - 9: fragment UserFragment on User { - 10: clientField - ^ - 11: } + Source: GraphQL request:10:3 + 9 | fragment UserFragment on User { + 10 | clientField + | ^ + 11 | } `; @@ -153,17 +153,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Unexpected directive: @stream. This directive can only be used on fields/fragments that are fetched from the server schema, but it is used inside a client-only selection. - Source (derived): GraphQL request (13:13) - 12: bar { - 13: users @stream(initial_count: 1, label: "StreamedActorsLabel") { - ^ - 14: id + Source (derived): GraphQL request:13:13 + 12 | bar { + 13 | users @stream(initial_count: 1, label: "StreamedActorsLabel") { + | ^ + 14 | id - Source: GraphQL request (11:3) - 10: id - 11: foo { - ^ - 12: bar { + Source: GraphQL request:11:3 + 10 | id + 11 | foo { + | ^ + 12 | bar { `; @@ -199,17 +199,17 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Unexpected directive: @stream. This directive can only be used on fields/fragments that are fetched from the server schema, but it is used inside a client-only selection. - Source (derived): GraphQL request (11:8) - 10: id - 11: foos @stream(initial_count: 1, label: "StreamedActorsLabel") { - ^ - 12: bar + Source (derived): GraphQL request:11:8 + 10 | id + 11 | foos @stream(initial_count: 1, label: "StreamedActorsLabel") { + | ^ + 12 | bar - Source: GraphQL request (11:3) - 10: id - 11: foos @stream(initial_count: 1, label: "StreamedActorsLabel") { - ^ - 12: bar + Source: GraphQL request:11:3 + 10 | id + 11 | foos @stream(initial_count: 1, label: "StreamedActorsLabel") { + | ^ + 12 | bar `; @@ -411,16 +411,16 @@ THROWN EXCEPTION: Error: Encountered 1 error(s): - Unexpected directive: @stream. This directive can only be used on fields/fragments that are fetched from the server schema, but it is used inside a client-only selection. - Source (derived): GraphQL request (9:7) - 8: clientComments(first: 10) - 9: @stream_connection( - ^ - 10: key: "NodeQuery_clientComments" + Source (derived): GraphQL request:9:7 + 8 | clientComments(first: 10) + 9 | @stream_connection( + | ^ + 10 | key: "NodeQuery_clientComments" - Source: GraphQL request (8:7) - 7: ... on Story { - 8: clientComments(first: 10) - ^ - 9: @stream_connection( + Source: GraphQL request:8:7 + 7 | ... on Story { + 8 | clientComments(first: 10) + | ^ + 9 | @stream_connection( `; diff --git a/packages/relay-test-utils-internal/package.json b/packages/relay-test-utils-internal/package.json index 05efb172532e4..f0c2726f92522 100644 --- a/packages/relay-test-utils-internal/package.json +++ b/packages/relay-test-utils-internal/package.json @@ -17,7 +17,7 @@ "relay-compiler": "5.0.0" }, "peerDependencies": { - "graphql": "^14.2.0" + "graphql": "^14.4.0" }, "directories": { "": "./" diff --git a/packages/relay-test-utils/package.json b/packages/relay-test-utils/package.json index 6168a8b127b4b..9dae8b79d326e 100644 --- a/packages/relay-test-utils/package.json +++ b/packages/relay-test-utils/package.json @@ -16,7 +16,7 @@ "relay-runtime": "5.0.0" }, "peerDependencies": { - "graphql": "^14.2.0" + "graphql": "^14.4.0" }, "directories": { "": "./" diff --git a/yarn.lock b/yarn.lock index aee368208db9b..f8d2affd90e98 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3259,10 +3259,10 @@ graceful-fs@^4.0.0, graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2 resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA== -graphql@^14.0.0, graphql@^14.2.0: - version "14.3.1" - resolved "https://registry.yarnpkg.com/graphql/-/graphql-14.3.1.tgz#b3aa50e61a841ada3c1f9ccda101c483f8e8c807" - integrity sha512-FZm7kAa3FqKdXy8YSSpAoTtyDFMIYSpCDOr+3EqlI1bxmtHu+Vv/I2vrSeT1sBOEnEniX3uo4wFhFdS/8XN6gA== +graphql@^14.0.0, graphql@^14.4.0: + version "14.4.0" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-14.4.0.tgz#e97086acfc0338e4fdc8f7dba519c6b8a6badfd9" + integrity sha512-E55z1oK6e4cGxCqlSsRWytYDPcIUxky3XkbuQUf6TIjCmn6C7CuBJpmkMF1066q95yPAGOZVPTVT7jABKbRFSA== dependencies: iterall "^1.2.2"