You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using extend type Query without type Query leads to Linter violation error being reported via Apollo Service Check when using schema file option.
#3040
Open
ngupta53 opened this issue
Jun 18, 2024
· 3 comments
I have a type definition defined using extend query in our schema like below -
extend type Query {
testGraphQl(id: Int!): TestGraphQl!
}
I do not have type Query defined anywhere in the schema.
I want to use schema file option to run the schema checks and pass the generated schema to it. To generate the schema graphql file, I am using @apollo/subgraph printSubgraphSchema() method to get the schema output and then write to a file.
The schema file that gets generated has a type Query string appearing on top of extend type Query, something like this -
type Query
extend type Query {
testGraphQl(id: Int!): TestGraphQl!
}
When I run the schema check, it complains about the Linter violation error 'DOES_NOT_PARSE' due to "The schema linter raises this violation if it attempts to read a malformed GraphQL schema."
The printSubgraphSchema() method itself outputs that type Query string and then the Linter reports it. This should not be happening. Raising this issue to look into this and fix this issue.
Link to Reproduction
n/a
Reproduction Steps
Define a type extending type Query without having type Query specified anywhere in the schema.
Generate a schema file using printSubgraphSchema() method of @apollo/subgraph to print the schema output and write it to a file.
Note that generated schema graphql file has additional type Query present.
type Query
extend type Query {
testGraphQl(id: Int!): TestGraphQl!
}
Run subgraph schema check using the generate schema file passing the schema file option. Note that the schema check fails with Linter violation error 'DOES_NOT_PARSE' due to "The schema linter raises this violation if it attempts to read a malformed GraphQL schema."
The text was updated successfully, but these errors were encountered:
type TestGraphQl {
id: Int!
}
extend type Query {
testGraphQl(id: Int!): TestGraphQl!
}
It's a valid subgraph schema, but it is not a valid GraphQL schema by itself (since type Query is not defined before extending it). It's unclear to me how you went from step (1) to step (2). How did you construct a GraphQLSchema object when the input schema is not a valid GraphQL schema?
Issue Description
I have a type definition defined using extend query in our schema like below -
I do not have
type Query
defined anywhere in the schema.I want to use schema file option to run the schema checks and pass the generated schema to it. To generate the schema graphql file, I am using @apollo/subgraph printSubgraphSchema() method to get the schema output and then write to a file.
The schema file that gets generated has a
type Query
string appearing on top of extend type Query, something like this -When I run the schema check, it complains about the Linter violation error 'DOES_NOT_PARSE' due to "The schema linter raises this violation if it attempts to read a malformed GraphQL schema."
The
printSubgraphSchema()
method itself outputs thattype Query
string and then the Linter reports it. This should not be happening. Raising this issue to look into this and fix this issue.Link to Reproduction
n/a
Reproduction Steps
type Query
specified anywhere in the schema.printSubgraphSchema()
method of @apollo/subgraph to print the schema output and write it to a file.The text was updated successfully, but these errors were encountered: