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
I put this in the original issue regarding type extension (#483), but was unable to reopen it, so I put a new issue in as I believe this is really bad problem to have.
The problem is that the parser is fine with the extend keyword and properly builds an AST, but buildSchema does not properly insert the extend fields. If buildSchema does not handle it, I think having parse properly parse an AST might be a mistake, especially with so little documentation around the feature. Either buildSchema should compile the extend fields into the schema, or should error out on the extend syntax. Otherwise, it is very misleading and a less than obvious issue to hunt down.
The minimal example is below
import{buildSchema,graphql}from'graphql';constschema=buildSchema(`type QuerySubset { hello: String}type Queries { querySubset: QuerySubset}extend type Queries { hello: String}type Query { Queries: Queries}schema { query: Query}`);constrootResolver={Queries: {querySubset: {hello: (): string=>'hello world',},hello: (): string=>'hello world',},};// Works finegraphql(schema,`{ Queries { querySubset { hello } } }`,rootResolver).then(response=>{console.log(response);});// Errors out with 'Cannot query field "hello" on type "Queries".'graphql(schema,`{ Queries { hello } }`,rootResolver).then(response=>{console.log(response);});
The text was updated successfully, but these errors were encountered:
Thanks for the report, @dyst5422. I just filed #922 which describes the fixing task for this issue.
As you describe above, buildASTSchema() is intended to build fully formed schema, while extendSchema() is intended to extend existing fully formed schema with new fields, typically for use in client-side or intermediate-only representations where the ultimate server only knows of a subset of the final definition.
I think your suggestion to throw an error is a great one, that would make debugging this far easier.
I put this in the original issue regarding type extension (#483), but was unable to reopen it, so I put a new issue in as I believe this is really bad problem to have.
The problem is that the parser is fine with the extend keyword and properly builds an AST, but buildSchema does not properly insert the extend fields. If
buildSchema
does not handle it, I think havingparse
properly parse an AST might be a mistake, especially with so little documentation around the feature. Either buildSchema should compile the extend fields into the schema, or should error out on theextend
syntax. Otherwise, it is very misleading and a less than obvious issue to hunt down.The minimal example is below
The text was updated successfully, but these errors were encountered: