graphql-tools
graphql-tools copied to clipboard
Support array of documents from custom loader
Is your feature request related to a problem? Please describe.
I need to support multiple GraphQL schemas in frontend, and need to implement custom loader to pick correct GraphQL operations. However, I'm now stuck as GraphQL codegen uses @graphql-tools/load, and it's custom loader support doesn't allow me to return multiple documents from the loader. If i combine all operations from different files into single document, then GraphQL codegen generated code wrong.
Describe the solution you'd like
collectCustomLoader
could check if result of running loader is an array, and run addResultOfCustomLoader
for each of the items.
Describe alternatives you've considered
Currently I don't have workaround for this.
Additional context
I have defined loader like below. Additionally it would be very helpful if you could specify function as loader instead of needing to go via JS file.
documents: {
"src/**/*.{ts,tsx}": {
loader: "./my-custom-loader.js"
}
},