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

Blank types for future extension? #293

Closed
Qard opened this issue Mar 18, 2017 · 6 comments
Closed

Blank types for future extension? #293

Qard opened this issue Mar 18, 2017 · 6 comments

Comments

@Qard
Copy link

Qard commented Mar 18, 2017

So I'm trying to make a modularized schema and want to combine that with type extension. The problem I'm running into is that I want to put my queries and mutations with my modularized types, but that leaves nothing to put in the starting Query and Mutation types.

I tried putting this at the start of my typeDefs array:

type RootMutation {}
type RootQuery {}
schema {
  query: RootQuery
  mutation: RootMutation
}

Sadly, when I try to run my app I get an error saying RootQuery fields must be an object with field names as keys or a function which returns such an object..

Is there a better way to achieve this?

@winsontam
Copy link

+1

@stubailo
Copy link
Contributor

Yeah this is definitely an issue - it would be best to fix it in the upstream GraphQL.js library, since we use that for parsing the schema string into a schema object.

https://github.com/graphql/graphql-js

Alternatively, we can add some hacks like inserting a _blank field inside Query automatically, then removing it in makeExecutableSchema.

@thunder7553
Copy link

Why would not it possible to extend a non-existing type? so if the type does not exist, it will be assumed that it is empty. If I understand correctly, "extend" is an extension to the schema. At least I could not see it in the graphql docs.

@helfer
Copy link
Contributor

helfer commented Jun 28, 2017

This is something that would have to be implemented in graphql-js.

@helfer helfer closed this as completed Jun 28, 2017
@medv
Copy link

medv commented Sep 19, 2017

Here's a little template for anyone else stumbling on this issue during this train of thought.
https://gist.github.com/medv/b7af4d8d4a9423871d863205e38d5f14

You can also do it @lokhmakov way, which might be better depending on what you want: #186

@chrisregnier
Copy link

For anyone else looking for progress on this, here's an associated issue in graphql-js (graphql/graphql-js#937)

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

7 participants