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

GraphiQL error when following graphql-ruby - Queries instructions #150

Closed
SebastianSzturo opened this issue Jul 22, 2017 · 3 comments
Closed

Comments

@SebastianSzturo
Copy link

If I follow current instructions in the graphql-ruby - Queries chapter I see following error in the GraphiQL console:

Error: Mutation fields must be an object with field names as keys or a function which returns such an object.
    at invariant (http://localhost:3000/assets/graphiql/rails/graphiql-0.10.2.self-b1f3838c6df9bb8fb4d30315dcdb431c4e3c5be8f8827635360232b8019d65bd.js?body=1:24179:11)
    at defineFieldMap (http://localhost:3000/assets/graphiql/rails/graphiql-0.10.2.self-b1f3838c6df9bb8fb4d30315dcdb431c4e3c5be8f8827635360232b8019d65bd.js?body=1:27207:27)
    at GraphQLObjectType.getFields (http://localhost:3000/assets/graphiql/rails/graphiql-0.10.2.self-b1f3838c6df9bb8fb4d30315dcdb431c4e3c5be8f8827635360232b8019d65bd.js?body=1:27164:44)
    at typeMapReducer (http://localhost:3000/assets/graphiql/rails/graphiql-0.10.2.self-b1f3838c6df9bb8fb4d30315dcdb431c4e3c5be8f8827635360232b8019d65bd.js?body=1:28869:25)
    at Array.reduce (<anonymous>)
    at new GraphQLSchema (http://localhost:3000/assets/graphiql/rails/graphiql-0.10.2.self-b1f3838c6df9bb8fb4d30315dcdb431c4e3c5be8f8827635360232b8019d65bd.js?body=1:28758:34)
    at buildClientSchema (http://localhost:3000/assets/graphiql/rails/graphiql-0.10.2.self-b1f3838c6df9bb8fb4d30315dcdb431c4e3c5be8f8827635360232b8019d65bd.js?body=1:30166:10)
    at http://localhost:3000/assets/graphiql/rails/graphiql-0.10.2.self-b1f3838c6df9bb8fb4d30315dcdb431c4e3c5be8f8827635360232b8019d65bd.js?body=1:2140:55
    at <anonymous>

This is due to rails generate graphql:install generating a schema that includes the mutation type, but at this point in the tutorial it is still empty.

GraphqlTutorialSchema = GraphQL::Schema.define do
  mutation(Types::MutationType)
  query(Types::QueryType)
end

We either need to make sure that we remove mutation(Types::MutationType) from this file before opening GraphiQL or adding a dummy mutation in this chapter.

I am not the best content writer, so I did not open a PR :P

@roberthopman
Copy link
Contributor

@SebastianSzturo i got the same error, made a pull request for this, but the whole tutorial seems to be in need of an update :)

@conradwt
Copy link

@SebastianSzturo This issue has been resolved within graphql-ruby by PR #922

@nikolasburk
Copy link
Contributor

Thanks for the discussion everyone 🙌

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

4 participants