Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Bug in buildASTSchema when mutations are passed #100

Closed
nemanja-stanarevic opened this issue Aug 2, 2015 · 1 comment
Closed

Bug in buildASTSchema when mutations are passed #100

nemanja-stanarevic opened this issue Aug 2, 2015 · 1 comment

Comments

@nemanja-stanarevic
Copy link
Contributor

All, great work all around on graphql reference implementation, it's incredibly helpful.

I have been using the schema DSL parser and buildASTSchema to materialize the schema and noticed a small bug in utilities/buildASTSchema. Specifically, when both queryTypeName and mutationTypeName are passed to the buildASTSchema, the schema is not constructed correctly - query is missing.

I traced the bug down to the lines 150-157 of utilities/buildASTSchema, where if mutationTypeName is passed, schema object is constructed with the queryTypeName string instead of queryType object:

  if (isNullish(mutationTypeName)) {
    schema = new GraphQLSchema({query: queryType});
  } else {
    schema = new GraphQLSchema({
      query: queryTypeName,
      mutation: produceTypeDef(astMap[mutationTypeName]),
    });
  }

This should fix it -

  if (isNullish(mutationTypeName)) {
    schema = new GraphQLSchema({query: queryType});
  } else {
    schema = new GraphQLSchema({
      query: queryType,
      mutation: produceTypeDef(astMap[mutationTypeName]),
    });
  }

Note that this slipped since buildASTSchema tests don't include a case when both mutation and query are passed. I am happy to fix this, add a test and submit a PR, if welcome.

@dschafer
Copy link
Contributor

dschafer commented Aug 3, 2015

Thanks for the report and PR! Just pushed 0.2.4 which should contain a fix for this issue!

@dschafer dschafer closed this as completed Aug 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants