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

Fix error when merging schema without a query #746

Closed
wants to merge 2 commits into from
Closed

Fix error when merging schema without a query #746

wants to merge 2 commits into from

Conversation

balinthaller
Copy link

This fixes a case when you try to merge a schema which has no query defined with an arbitrary one.
Issues: #639 #659

TODO:

  • If this PR is a new feature, reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass
  • Update CHANGELOG.md with your change. Include a description of your change, link to PR (always) and issue (if applicable). Add your CHANGELOG entry under vNEXT. Do not create a new version number for your change yourself.

@apollo-cla
Copy link

@hallerio: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@balinthaller
Copy link
Author

Tests on older node versions seem to be failing because of graphql.js requiring a root Query for each schema to be merged. Does the GraphQL spec require this or is it a bug?

@freiksenet
Copy link
Contributor

It's fixed in #527. Sorry that you had to do that extra work!

@freiksenet freiksenet closed this Apr 20, 2018
@geek
Copy link

geek commented Apr 25, 2018

I'm still running into this issue with v3.0.0...

{"errors":[{"message":"Query root type must be provided.","locations":[{"line":1,"column":12}],"path":["createPerson"]}],"data":null}

This is the result of merging 2 executable schemas, the first with the original structure:

     type Person {
        id: ID!
        firstname: String!
        lastname: String!
      }

      type Query {
        person(firstname: String!): Person!
      }

The second looks like this:

    const schema2 = `
      type Person {
        id: ID!
        firstname: String!
        lastname: String!
      }

      type Mutation {
        createPerson(firstname: String!, lastname: String!): Person!
      }
    `;

However, the problem goes away if I add a query to the second schema before the merge.

@stomvi
Copy link

stomvi commented May 1, 2018

Still get the error using graphql-tools v3.0.0.

First schema:

type Query {
  hello: String!
}

Second schema:

type Mutation {
  test: String!
}

Query:

mutation {
  test
}

returned data:

{
  "errors": [
    {
      "message": "Query root type must be provided.",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "test"
      ]
    }
  ],
  "data": null
}

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

Successfully merging this pull request may close these issues.

None yet

5 participants