Feature Request: Provide mesh config programmatically via an API #598
-
Hello wonderful team. I have the following idea for a feature which I believe would increase the usability of graphql-mesh. DescriptionIn the following I would refer to using graphql-mesh not as a standalone server but as part of an existing server / existing codebase. The idea is that graphql-mesh exposes an API or an option inside of In other words:
Example use caseMy team and I would really like to use graphql-mesh inside of our existing server as anything else is not an option for us at the moment. However, our existing server is using specific webpack development and production configurations. At the end, we deploy a simple Further, use case is using development tools such as TS/ FLow/ Jest, Babel, etc. Proposed solutionLooking at your code I found out that inside Example for how it could look like without breaking API const resolversObj = {
// ...
}
const queryComposerResolverFn = (next) => (...args) => // ...
const meshConfig = {
additionalResolvers: resolversObj,
transforms: {
resolversComposition: {
resolver: 'Query.*',
composer: queryComposerResolverFn
}
}
}
findAndParseConfig({
customConfig: meshConfig
}) I would be happy to hear your feedback about such a feature |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
You can use |
Beta Was this translation helpful? Give feedback.
-
Thanks for the suggested solution. I somehow missed it before. However I took a look now and I can say it partially covers what I initially suggested. It looks like the However, the // transforms object
...
{
composer: "./src/isNotAuth".
resolver: "Mutation.*"
} So the actual import of a module happens inside Probably a workaround this would be to extend the class with my custom one, where I override the resolversComposition[resolver] = typeof composer === 'function' ? composer : loadFromModuleExportExpressionSync(composer, 'default'); // Async is not available What do you think @ardatan |
Beta Was this translation helpful? Give feedback.
-
That's what I am thinking of. We should refactor all handlers and transforms to move external module loading logic outside of them. I am not sure about supporting functions as part of initial config because the schema of configuration is generated from GraphQL. But I'll figure it out soon and keep you posted. |
Beta Was this translation helpful? Give feedback.
That's what I am thinking of. We should refactor all handlers and transforms to move external module loading logic outside of them. I am not sure about supporting functions as part of initial config because the schema of configuration is generated from GraphQL. But I'll figure it out soon and keep you posted.