Use functions for custom mutations and queries#118
Use functions for custom mutations and queries#118Secretmapper wants to merge 4 commits intoRisingStack:masterfrom
Conversation
src/schema/schema.js
Outdated
| }, { | ||
| queries: customQueries, | ||
| mutations: customMutations | ||
| queries: customQueries(types), |
There was a problem hiding this comment.
how about: _.isFunction(customQueries) ? customQueries(types) : customQueries?
There was a problem hiding this comment.
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
getSchemais 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.