-
Notifications
You must be signed in to change notification settings - Fork 50
Use functions for custom mutations and queries #118
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
base: master
Are you sure you want to change the base?
Conversation
src/schema/schema.js
Outdated
}, { | ||
queries: customQueries, | ||
mutations: customMutations | ||
queries: customQueries(types), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about: _.isFunction(customQueries) ? customQueries(types) : customQueries
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it won't be a breaking change then
@tothandras Ah, that's even better, thanks! I'm about to hit the sack but I'll submit another commit tomorrow with tests. |
@Secretmapper I had a few minutes :) hope you don't mind! |
@tothandras Thanks! Another thing I forgot, we also needed to expose the |
Sure, if you need that, but we are about to process every field, because it seems we would need that for #112! :) |
The current customMutations and customQueries are powerful, but the types aren't exposed so it is impossible to use the generated graphQLTypes on customQueries/Mutations.
example:
is not possible since the changedMaterial doesn't have the necessary type, since the type will only be exposed once
getSchema
is called and by then it'd already be too late.What I propose is to pass in a function for both customMutations and Queries, so that the types can be passed dynamically:
I realize this is a breaking change, (and I'm not even sure if the above is actually impossible without my PR), so wanted to see what you think @tothandras . If you think the approach is good I'll write tests for it.