-
Notifications
You must be signed in to change notification settings - Fork 66
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
Allow extending root fields #272
Comments
Thanks for raising this @nhuesmann. Educated myself a bit tonight around this topic. SDL WayModularized schemas work in schema-first approach via the type Query {
a: String
}
extend type Query {
b: String
}
extend type Query {
c: String
} Is equivalent to: type Query {
a: String
b: String
c: String
}
Nexus WayNexus models queryType({
definition(t){
t.string('a')
}
})
queryField("b", {
type: 'String',
resolve: () => 'foo',
})
queryField("c", {
type: 'String',
resolve: () => 'foo',
}) Is equivalent to: queryType({
definition(t){
t.string('a', () => 'foo')
t.string('b', () => 'foo')
t.string('c', () => 'foo')
}
}) Santa Way (proposal)I'm thinking that queryType({
definition(t){
t.string('a')
}
})
queryType({
definition(t){
t.string('b')
}
})
queryType({
definition(t){
t.string('c')
}
}) Would be equivalent to: queryType({
definition(t){
t.string('a', () => 'foo')
t.string('b', () => 'foo')
t.string('c', () => 'foo')
}
}) I think this is a good direction because:
No obvious reason comes to mind why this proposed merging behaviour might be undesirable. |
@nhuesmann FYI I'm rephrasing the title of this issue to be able the problem rather than solution. |
@jasonkuhrt I love it, I agree with all your points. Changing |
Excellent input, @jasonkuhrt. Just wondering, since |
We indeed forgot to expose some part of the nexus surface api, I started a draft here #276 (exposing the rest of the nexus api without your proposal yet @jasonkuhrt) Regarding your proposal, there is a problem: Right now, what we could do is use Reason being that you should define these configurations on the main eg:
We could probably have an internal nexus plugin to warn if multiple root types were defined with different configurations, but it still makes the API error prone. Unless we find a better solution, I'd personally stick to the nexus API. WDYT? |
Some ideas;
Not sure yet, will think more about it. I like 1 so far. |
Dug into this yesterday and this morning.
By moving the type config to each instance of Furthermore, keeping type configuration local to each instance of the root type is not an inherently complex task but requires a substantial refactor on
By the time we get into typegen, we loose all the context about which type config is associated with which field. We need to refactor nexus to keep the type configuration associated with every field of the type
Plugins can add configuration properties to object types. Thanks to the
Note: We might have less problems if we take the opinionated approach of making root types special (Query/Mutation/Subscription) and not expending the concept to any output types. I did not investigated that approach, but it will probably require a lot of refactor too as |
I think Nexus's
mutationField
/queryField
create a simple, intuitive, and clean way to have a modular schema. I would love to see them made available throughgraphql-santa
.The text was updated successfully, but these errors were encountered: