graphql-tools icon indicating copy to clipboard operation
graphql-tools copied to clipboard

Support array of documents from custom loader

Open jlitola opened this issue 9 months ago • 0 comments

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"
				}
			},

jlitola avatar May 03 '24 13:05 jlitola