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/relay-compiler/codegen/__tests__/__snapshots__/RelayCodeGenerator-test.js.snap b/packages/relay-compiler/codegen/__tests__/__snapshots__/RelayCodeGenerator-test.js.snap index ca50dd51f7957..22b11f95a9c95 100644 --- a/packages/relay-compiler/codegen/__tests__/__snapshots__/RelayCodeGenerator-test.js.snap +++ b/packages/relay-compiler/codegen/__tests__/__snapshots__/RelayCodeGenerator-test.js.snap @@ -13,10 +13,10 @@ ERROR: NormalizationCodeGenerator: Complex argument values (Lists or InputObjects with nested variables) are not supported. Source: GraphQL request:2:17 -1: query TestQuery($date: String) { -2: items(filter: {date: $date}) { - ^ -3: date +1 | query TestQuery($date: String) { +2 | items(filter: {date: $date}) { + | ^ +3 | date `; 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 bd1fabcdcfdc3..38ef9a72a4f44 100644 --- a/packages/relay-compiler/codegen/__tests__/__snapshots__/compileRelayArtifacts-test.js.snap +++ b/packages/relay-compiler/codegen/__tests__/__snapshots__/compileRelayArtifacts-test.js.snap @@ -3287,19 +3287,19 @@ Error: Encountered 2 error(s): - $commentsKey: String. Source (derived): GraphQL request:25:26 - 24: key: "FeedbackFragment_comments" - 25: dynamicKey_UNSTABLE: $commentsKey - ^ - 26: filters: ["orderby"] + 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"] + 24 | key: "FeedbackFragment_comments" + 25 | dynamicKey_UNSTABLE: $commentsKey + | ^ + 26 | filters: ["orderby"] `; @@ -4152,34 +4152,32 @@ 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) { +2 | fragment RefetchableFragment on Query @refetchable(queryName: "RefetchableFragme + | ^ + | ntQuery") @argumentDefinitions(id: {type: "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) { +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: } +6 | name +7 | ...Profile @arguments(includeProfile: true) + | ^ +8 | } Source: GraphQL request:21:9 -20: node { -21: ...Profile - ^ -22: } +20 | node { +21 | ...Profile + | ^ +22 | } Source: GraphQL request:21:9 -20: node { -21: ...Profile - ^ -22: } +20 | node { +21 | ...Profile + | ^ +22 | } `; @@ -4928,16 +4926,16 @@ 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: } + 11 | emailAddresses + 12 | ...DeferredFragment @defer(label: "DeferredFragmentLabel") + | ^ + 13 | } Source (derived): GraphQL request:12:3 - 11: emailAddresses - 12: ...DeferredFragment @defer(label: "DeferredFragmentLabel") - ^ - 13: } + 11 | emailAddresses + 12 | ...DeferredFragment @defer(label: "DeferredFragmentLabel") + | ^ + 13 | } `; @@ -5335,16 +5333,16 @@ 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: } + 4 | me { + 5 | ...Profile @relay(mask: false) + | ^ + 6 | } Source: GraphQL request:9:26 - 8: - 9: fragment Profile on User @inline { - ^ - 10: id + 8 | + 9 | fragment Profile on User @inline { + | ^ + 10 | id `; @@ -5735,10 +5733,10 @@ 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 + 9 | fragment Profile on User @inline { + 10 | profilePicture(size: $pictureSize) { + | ^ + 11 | uri `; @@ -5773,10 +5771,10 @@ 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) { + 16 | @inline + 17 | @argumentDefinitions(sizeArg: { type: "[Int]", defaultValue: [50] }) { + | ^ + 18 | profilePicture(size: $sizeArg) { `; @@ -6582,16 +6580,16 @@ 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: } + 21 | ...MarkdownUserNameRenderer_name + 22 | @module(name: "BarMarkdownUserNameRenderer.react") + | ^ + 23 | } Source: GraphQL request:13:7 - 12: ...MarkdownUserNameRenderer_name - 13: @module(name: "FooMarkdownUserNameRenderer.react") - ^ - 14: } + 12 | ...MarkdownUserNameRenderer_name + 13 | @module(name: "FooMarkdownUserNameRenderer.react") + | ^ + 14 | } `; @@ -6784,16 +6782,16 @@ 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: } + 4 | hometown{ + 5 | nameWithArgs + | ^ + 6 | } Source: GraphQL request:2:1 - 1: # expected-to-throw - 2: query TestQuery { - ^ - 3: node { + 1 | # expected-to-throw + 2 | query TestQuery { + | ^ + 3 | node { `; @@ -7473,16 +7471,16 @@ 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: } + 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 + 12 | ...MarkdownUserNameRenderer_name + 13 | @module(name: "FooMarkdownUserNameRenderer.react") + | ^ + 14 | ...PlainUserNameRenderer_name `; @@ -12998,16 +12996,16 @@ 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: } + 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: + 9 | fragment User_user on User + 10 | @argumentDefinitions(isRelative: {type: "Boolean!", defaultValue: false}) { + | ^ + 11 | `; @@ -13424,17 +13422,16 @@ 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: } + 15 | __typename + 16 | ...ProfilePhoto @arguments(size: $size) + | ^ + 17 | } GraphQL request:19:1 - 18: - 19: fragment ProfilePhoto on User { - ^ - 20: profilePicture(size: [100]) { - + 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 59963676a4b58..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'; @@ -110,7 +110,7 @@ function createCombinedError( `${prefix}Encountered ${errors.length} error(s):\n` + errors .map(error => - (error instanceof GraphQLError ? printError(error) : String(error)) + String(error) .split('\n') .map((line, index) => (index === 0 ? `- ${line}` : ` ${line}`)) .join('\n'), @@ -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,98 +192,6 @@ function printLocations(locations: $ReadOnlyArray): Array { return printedLocations; } -/** - * Prints a GraphQLError to a string, representing useful location information - * about the error's position in the source. - */ -function printError(error: GraphQLError): string { - const printedLocations = []; - if (error.nodes) { - for (const node of error.nodes) { - if (node.loc) { - printedLocations.push( - highlightSourceAtLocation( - node.loc.source, - getLocation(node.loc.source, node.loc.start), - ), - ); - } - } - } else if (error.source && error.locations) { - const source = error.source; - for (const location of error.locations) { - printedLocations.push(highlightSourceAtLocation(source, location)); - } - } - return printedLocations.length === 0 - ? error.message - : [error.message, ...printedLocations].join('\n\n') + '\n'; -} - -/** - * 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/__tests__/__snapshots__/RelayParser-test.js.snap b/packages/relay-compiler/core/__tests__/__snapshots__/RelayParser-test.js.snap index 60b2c7359219a..aa9bfba6b3302 100644 --- a/packages/relay-compiler/core/__tests__/__snapshots__/RelayParser-test.js.snap +++ b/packages/relay-compiler/core/__tests__/__snapshots__/RelayParser-test.js.snap @@ -17,11 +17,10 @@ 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: ) { - + 3 | id: {type: "ID"} + 4 | size: {type: "[Int]", defaultValu: [100]} # uh-oh, typo + | ^ + 5 | ) { `; exports[`RelayParser matches expected output: client-fields.graphql 1`] = ` @@ -933,11 +932,10 @@ Error: RelayParser: Encountered 1 error(s): - Invalid directives @match found on FRAGMENT_DEFINITION. Source: document \`Example\` file: \`GraphQL request\` GraphQL request:2:26 - 1: # expected-to-throw - 2: fragment Example on User @match(key: "Example"){ - ^ - 3: friends { - + 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`] = ` @@ -956,17 +954,16 @@ Error: RelayParser: Encountered 1 error(s): - Invalid directives @module, @match found on QUERY. Source: document \`TestQuery\` file: \`GraphQL request\` GraphQL request:2:27 - 1: # expected-to-throw - 2: query TestQuery($id: ID!) @module @match{ - ^ - 3: foo: node(id: $id) { + 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) { - + 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`] = ` @@ -991,11 +988,10 @@ Error: RelayParser: Encountered 1 error(s): - Invalid directives @module found on FIELD. Source: document \`Example\` file: \`GraphQL request\` GraphQL request:6:24 - 5: node { - 6: profilePicture @module(preset: $preset) { - ^ - 7: uri - + 5 | node { + 6 | profilePicture @module(preset: $preset) { + | ^ + 7 | uri `; exports[`RelayParser matches expected output: enum-values.graphql 1`] = ` @@ -1179,27 +1175,24 @@ 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 - + 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 - + 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 - + 19 | me { + 20 | profilePicture(preset: [LARGE]) { # error: list of enum, not enum + | ^ + 21 | uri `; exports[`RelayParser matches expected output: field-arguments.graphql 1`] = ` @@ -2787,17 +2780,16 @@ 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, + 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 - + 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`] = ` @@ -3849,17 +3841,16 @@ 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: } + 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) { - + 5 | + 6 | fragment ChildFragment on User { + | ^ + 7 | profilePicture(size: $pictureSize) { `; exports[`RelayParser matches expected output: fragment-with-undefined-variable-arguments.invalid.graphql 1`] = ` @@ -3882,17 +3873,16 @@ 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: } + 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) { - + 5 | + 6 | fragment ChildFragment on User { + | ^ + 7 | profilePicture(size: $pictureSize) { `; exports[`RelayParser matches expected output: fragment-with-unnecessary-unchecked-arguments.invalid.graphql 1`] = ` @@ -3922,11 +3912,10 @@ 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: } - + 11 | } + 12 | ...Foo @uncheckedArguments_DEPRECATED(localId: $id) + | ^ + 13 | } `; exports[`RelayParser matches expected output: inline-untyped-fragment.graphql 1`] = ` @@ -5055,27 +5044,24 @@ 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" - + 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 { - + 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 { - + 21 | query LiteralListArgumentQuery3 { + 22 | route(waypoints: "waypoint") { # error: string not list + | ^ + 23 | steps { `; exports[`RelayParser matches expected output: literal-object-argument.graphql 1`] = ` @@ -5235,27 +5221,24 @@ 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: }) { - + 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: }) { - + 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 - + 18 | query LiteralObjectArgument3 { + 19 | checkinSearchQuery(query: FACEBOOK) { # error: enum not object + | ^ + 20 | query `; exports[`RelayParser matches expected output: null-values.graphql 1`] = ` @@ -5397,11 +5380,10 @@ 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 - + 2 | query NullValuesQuery { + 3 | node_id_required(id: null) { + | ^ + 4 | id `; exports[`RelayParser matches expected output: object-argument.graphql 1`] = ` @@ -5871,11 +5853,10 @@ 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") { - + 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`] = ` @@ -5883,11 +5864,10 @@ exports[`RelayParser should error on fragment spread arguments with literal out - Expected a value matching type 'Int'. GraphQL request:4:38 - 3: # Number.MAX_SAFE_INTEGER is 9007199254740991 - 4: ...TestChild @arguments(foo: 10000000000000000) - ^ - 5: } - " + 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`] = ` @@ -5895,15 +5875,14 @@ exports[`RelayParser should error when parsing fragment that references undeclar - Variable '$id' was used in locations expecting the conflicting types 'ID' and 'Int'. Source: document \`TestFragment\` file: \`GraphQL request\` GraphQL request:2:14 - 1: fragment TestFragment on Query { - 2: node(id: $id) { - ^ - 3: id + 1 | fragment TestFragment on Query { + 2 | node(id: $id) { + | ^ + 3 | id GraphQL request:5:18 - 4: } - 5: task(number: $id) { - ^ - 6: title - " + 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 7bdb4bd9fdf68..466d17dd18460 100644 --- a/packages/relay-compiler/core/__tests__/__snapshots__/RelayPrinter-test.js.snap +++ b/packages/relay-compiler/core/__tests__/__snapshots__/RelayPrinter-test.js.snap @@ -162,11 +162,10 @@ 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 - + 2 | fragment UserFragment on User { + 3 | checkins(environments: "WEB") { + | ^ + 4 | __typename `; exports[`GraphQLIRPrinter matches expected output: string-enum-fragment-arg.graphql 1`] = ` @@ -206,9 +205,8 @@ 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 - + 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 7ec4f1023f940..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 @@ -547,10 +547,10 @@ 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 { + 7 | ... on Story { + 8 | comments @connection(key: "NodeQuery_comments") { + | ^ + 9 | edges { `; @@ -873,10 +873,10 @@ 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 { + 7 | ... on Story { + 8 | comments(first: 10) @connection(key: "invalid") { + | ^ + 9 | edges { `; @@ -907,11 +907,10 @@ 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 { - + 7 | ... on Story { + 8 | comments(first: 10) @connection(key: 10) { + | ^ + 9 | edges { `; exports[`RelayConnectionTransform matches expected output: invalid-connection-with-custom-handler.graphql 1`] = ` @@ -950,11 +949,10 @@ 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 { - + 7 | ... on Story { + 8 | comments(first: 10) @connection(key: "NodeQuery_comments", handler: 10) { + | ^ + 9 | edges { `; exports[`RelayConnectionTransform matches expected output: invalid-type.graphql 1`] = ` @@ -980,10 +978,10 @@ 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 + 7 | ... on Story { + 8 | actors @connection { + | ^ + 9 | name `; @@ -1187,10 +1185,10 @@ 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 { + 13 | ) { + 14 | commentEdges: edges { + | ^ + 15 | node { `; @@ -1231,9 +1229,9 @@ 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 + 20 | } + 21 | commentPageInfo: pageInfo { + | ^ + 22 | hasNextPage `; 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 6a283466f3e2f..d6af6b7a8ea65 100644 --- a/packages/relay-compiler/transforms/__tests__/__snapshots__/FlattenTransform-test.js.snap +++ b/packages/relay-compiler/transforms/__tests__/__snapshots__/FlattenTransform-test.js.snap @@ -34,16 +34,16 @@ 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 { + 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 + 8 | ... on User { + 9 | friendsAlias: friends(first: 5) { + | ^ + 10 | count `; @@ -81,16 +81,16 @@ 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 { + 13 | ... on User { + 14 | friends(first: 10) { + | ^ + 15 | edges { Source: GraphQL request:9:9 - 8: ... on User { - 9: friends(first: 5) { - ^ - 10: count + 8 | ... on User { + 9 | friends(first: 5) { + | ^ + 10 | count `; @@ -456,16 +456,16 @@ 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 + 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") + 3 | id + 4 | nameRenderer @match { + | ^ + 5 | ...PlainUserNameRenderer_name @module(name: "PlainUserNameRenderer.react") `; @@ -510,16 +510,16 @@ 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 + 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 + 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 a3bda0ec5ecfd..c180ad9b0af3b 100644 --- a/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayApplyFragmentArgumentTransform-test.js.snap +++ b/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayApplyFragmentArgumentTransform-test.js.snap @@ -304,22 +304,22 @@ 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! +1 | # expected-to-throw +2 | query TestQuery( + | ^ +3 | $id: ID! Source: GraphQL request:8:5 -7: id -8: ...Profile - ^ -9: } +7 | id +8 | ...Profile + | ^ +9 | } Source: GraphQL request:21:9 -20: node { -21: ...Profile - ^ -22: } +20 | node { +21 | ...Profile + | ^ +22 | } `; @@ -362,11 +362,10 @@ 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: } - + 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 eb17ce5c87eed..c0fed37c9a2b6 100644 --- a/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayDeferStreamTransform-test.js.snap +++ b/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayDeferStreamTransform-test.js.snap @@ -166,16 +166,16 @@ 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: } + 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") + 11 | emailAddresses + 12 | ...DeferredFragment @defer(label: "deferred") + | ^ + 13 | ...OtherDeferredFragment @defer(label: "deferred") `; @@ -361,16 +361,16 @@ 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 + 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 + 10 | id + 11 | actors @stream(initial_count: 1, label: "actors") { + | ^ + 12 | name `; @@ -470,10 +470,10 @@ 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 + 10 | id + 11 | actors @stream(label: "StreamedActorsLabel") { # invalid: missing initial_count + | ^ + 12 | name `; @@ -536,10 +536,10 @@ 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 + 10 | id + 11 | actors @stream(initial_count: 1, label: $label) { + | ^ + 12 | name `; @@ -571,10 +571,10 @@ 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: } + 11 | emailAddresses + 12 | ...DeferredFragment @defer(label: $label) + | ^ + 13 | } `; @@ -681,16 +681,16 @@ 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 + 15 | } + 16 | ... on User @defer { # invalid: duplicate label + | ^ + 17 | name Source: GraphQL request:12:15 - 11: emailAddresses - 12: ... on User @defer { - ^ - 13: id + 11 | emailAddresses + 12 | ... on User @defer { + | ^ + 13 | id `; @@ -757,10 +757,10 @@ 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 + 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 3c3a1a994f572..818bfa7690951 100644 --- a/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayMaskTransform-test.js.snap +++ b/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayMaskTransform-test.js.snap @@ -93,16 +93,16 @@ 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 + 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 + 7 | fragment NullableIDFragment on Query { + 8 | node(id: $id) { + | ^ + 9 | id `; @@ -133,16 +133,16 @@ 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 + 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 + 7 | fragment NullableIDFragment on Query { + 8 | node(id: $id) { + | ^ + 9 | id `; @@ -168,16 +168,16 @@ 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: ) { + 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 + 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 51cedc5ef35fd..efc85febefeb1 100644 --- a/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayMatchTransform-test.js.snap +++ b/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayMatchTransform-test.js.snap @@ -19,10 +19,10 @@ 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: } + 5 | ... on PlainUserNameRenderer { + 6 | js(module: "PlainUserNameRenderer.react") + | ^ + 7 | } `; @@ -55,16 +55,16 @@ 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: } + 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 + 16 | + 17 | fragment User_user on User { + | ^ + 18 | __typename `; @@ -83,11 +83,10 @@ Error: RelayParser: Encountered 1 error(s): - Expected at least one selection for non-scalar field 'nameRenderer' on type 'UserNameRenderer'. Source: document \`NameRendererFragment\` file: \`GraphQL request\`. GraphQL request:4:3 - 3: id - 4: nameRenderer @match - ^ - 5: } - + 3 | id + 4 | nameRenderer @match + | ^ + 5 | } `; exports[`RelayMatchTransform matches expected output: invalid-non-empty-selections.graphql 1`] = ` @@ -124,10 +123,10 @@ 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") + 4 | nameRenderer @match { + 5 | __typename + | ^ + 6 | ...PlainUserNameRenderer_name @module(name: "PlainUserNameRenderer.react") `; @@ -229,10 +228,10 @@ 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: } + 6 | ...MarkdownUserNameRenderer_name + 7 | @module(name: "MarkdownUserNameRenderer.react") @arguments(cond: true) + | ^ + 8 | } `; @@ -270,10 +269,10 @@ 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 { + 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 80e7432bdbacd..53d006b9109bf 100644 --- a/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayRefetchableFragmentTransform-test.js.snap +++ b/packages/relay-compiler/transforms/__tests__/__snapshots__/RelayRefetchableFragmentTransform-test.js.snap @@ -56,10 +56,10 @@ 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 + 1 | # expected-to-throw + 2 | fragment UserName on UserNameRenderable @refetchable(queryName: "RefetchableFragmentQuery") { + | ^ + 3 | name `; @@ -704,16 +704,16 @@ 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") { + 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") { + 9 | name + 10 | friends(after: $cursor, first: 10) + | ^ + 11 | @connection(key: "PaginationFragment_friends") { `; @@ -746,16 +746,16 @@ 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") { + 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") { + 9 | name + 10 | friends(after: "", first: $count) + | ^ + 11 | @connection(key: "PaginationFragment_friends") { `; @@ -795,16 +795,16 @@ 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") { + 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 { + 11 | friends(first: 1) { + 12 | edges { + | ^ + 13 | node { `; diff --git a/packages/relay-compiler/validations/__tests__/__snapshots__/validateRelayRequiredArugments-test.js.snap b/packages/relay-compiler/validations/__tests__/__snapshots__/validateRelayRequiredArugments-test.js.snap index 20c7c67bd695b..a460de9bf81f8 100644 --- a/packages/relay-compiler/validations/__tests__/__snapshots__/validateRelayRequiredArugments-test.js.snap +++ b/packages/relay-compiler/validations/__tests__/__snapshots__/validateRelayRequiredArugments-test.js.snap @@ -108,16 +108,16 @@ 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 + 4 | node { + 5 | body @customDirective { + | ^ + 6 | text Source: GraphQL request:3:1 - 2: - 3: query ViewerQuery { - ^ - 4: node { + 2 | + 3 | query ViewerQuery { + | ^ + 4 | node { `; @@ -139,16 +139,16 @@ 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: } + 4 | hometown{ + 5 | nameWithArgs + | ^ + 6 | } Source: GraphQL request:2:1 - 1: # expected-to-throw - 2: query TestQuery { - ^ - 3: node { + 1 | # expected-to-throw + 2 | query TestQuery { + | ^ + 3 | node { `; @@ -178,15 +178,15 @@ 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 { + 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 { + 1 | # expected-to-throw + 2 | fragment SomeComment on Comment { + | ^ + 3 | commentBody { `; 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 6a072b7f1c466..fa9c5f214c581 100644 --- a/packages/relay-compiler/validations/__tests__/__snapshots__/validateRelayServerOnlyDirectives-test.js.snap +++ b/packages/relay-compiler/validations/__tests__/__snapshots__/validateRelayServerOnlyDirectives-test.js.snap @@ -60,16 +60,16 @@ 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: } + 11 | emailAddresses + 12 | ...DeferredFragment @defer(label: "DeferredFragmentLabel") + | ^ + 13 | } Source (derived): GraphQL request:12:3 - 11: emailAddresses - 12: ...DeferredFragment @defer(label: "DeferredFragmentLabel") - ^ - 13: } + 11 | emailAddresses + 12 | ...DeferredFragment @defer(label: "DeferredFragmentLabel") + | ^ + 13 | } `; @@ -98,16 +98,16 @@ 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: } + 4 | id + 5 | ...UserFragment @defer(label: "DeferredFragmentLabel") + | ^ + 6 | } Source: GraphQL request:10:3 - 9: fragment UserFragment on User { - 10: clientField - ^ - 11: } + 9 | fragment UserFragment on User { + 10 | clientField + | ^ + 11 | } `; @@ -154,16 +154,16 @@ 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 + 12 | bar { + 13 | users @stream(initial_count: 1, label: "StreamedActorsLabel") { + | ^ + 14 | id Source: GraphQL request:11:3 - 10: id - 11: foo { - ^ - 12: bar { + 10 | id + 11 | foo { + | ^ + 12 | bar { `; @@ -200,16 +200,16 @@ 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 + 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 + 10 | id + 11 | foos @stream(initial_count: 1, label: "StreamedActorsLabel") { + | ^ + 12 | bar `; @@ -318,16 +318,16 @@ Error: Encountered 1 error(s): - Unexpected directive: @module. 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: GraphQL request:9:13 - 8: ...PlainUserNameRenderer_name - 9: @module(name: "PlainUserNameRenderer.react") - ^ - 10: ...MarkdownUserNameRenderer_name + 8 | ...PlainUserNameRenderer_name + 9 | @module(name: "PlainUserNameRenderer.react") + | ^ + 10 | ...MarkdownUserNameRenderer_name Source: GraphQL request:4:3 - 3: id - 4: foo { - ^ - 5: bar { + 3 | id + 4 | foo { + | ^ + 5 | bar { `; @@ -391,16 +391,16 @@ Error: Encountered 1 error(s): - Unexpected directive: @module. 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: GraphQL request:17:7 - 16: ...PlainUserNameRenderer_name - 17: @module(name: "PlainUserNameRenderer.react") - ^ - 18: ...MarkdownUserNameRenderer_name + 16 | ...PlainUserNameRenderer_name + 17 | @module(name: "PlainUserNameRenderer.react") + | ^ + 18 | ...MarkdownUserNameRenderer_name Source: GraphQL request:25:3 - 24: id - 25: foo { - ^ - 26: bar { + 24 | id + 25 | foo { + | ^ + 26 | bar { `; @@ -471,16 +471,16 @@ Error: Encountered 1 error(s): - Unexpected directive: @module. 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: GraphQL request:29:7 - 28: ...PlainUserNameRenderer_name - 29: @module(name: "PlainUserNameRenderer.react") - ^ - 30: ...MarkdownUserNameRenderer_name + 28 | ...PlainUserNameRenderer_name + 29 | @module(name: "PlainUserNameRenderer.react") + | ^ + 30 | ...MarkdownUserNameRenderer_name Source: GraphQL request:17:3 - 16: id - 17: foo { - ^ - 18: bar { + 16 | id + 17 | foo { + | ^ + 18 | bar { `; @@ -550,16 +550,16 @@ Error: Encountered 1 error(s): - Unexpected directive: @module. 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: GraphQL request:19:7 - 18: ...PlainUserNameRenderer_name - 19: @module(name: "PlainUserNameRenderer.react") - ^ - 20: ...MarkdownUserNameRenderer_name + 18 | ...PlainUserNameRenderer_name + 19 | @module(name: "PlainUserNameRenderer.react") + | ^ + 20 | ...MarkdownUserNameRenderer_name Source: GraphQL request:37:3 - 36: id - 37: foo { - ^ - 38: bar { + 36 | id + 37 | foo { + | ^ + 38 | bar { `; @@ -605,16 +605,16 @@ Error: Encountered 1 error(s): - Unexpected directive: @module. 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: GraphQL request:7:11 - 6: ...PlainUserNameRenderer_name - 7: @module(name: "PlainUserNameRenderer.react") - ^ - 8: ...MarkdownUserNameRenderer_name + 6 | ...PlainUserNameRenderer_name + 7 | @module(name: "PlainUserNameRenderer.react") + | ^ + 8 | ...MarkdownUserNameRenderer_name Source: GraphQL request:4:5 - 3: me { - 4: user { - ^ - 5: nameRenderer @match { + 3 | me { + 4 | user { + | ^ + 5 | nameRenderer @match { `; @@ -660,15 +660,15 @@ 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" + 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( + 7 | ... on Story { + 8 | clientComments(first: 10) + | ^ + 9 | @stream_connection( `;