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

Improve Package Reuse By Separating graphql.Request from graphql.ExecutionEngine

Open ghost opened this issue 2 years ago • 1 comments

Hi,

I am currently working on implementing a new execution engine tailored to a specific use-case of ours and have been able to successfully do so building on top of some of the components in this library. However, one part that has not been as smooth has been with graphql.Request.

I would like to reuse this type in its entirety but am unable to do so due to the document ast.Document field being private. This is not an issue in your implementation of graphql.ExecutionEngineV2 because they are in the same package so the &operation.document may be accessed when building the plan.Plan. I have had to create my own GraphQLRequest type so that I can access the document for this step.

My proposal would be to add a public getter (e.g. func (r *Request) GetParsedDocument or something) to graphql.Request. Additionally, if this feels like the right direction to go, to split Request out into its own package separate from execution engines. The execution engines would use the public interface and this could help improve the reuse / modularity of the packages.

I am happy to contribute this change if it is aligned with your vision for the project.

Thanks, Joel

ghost avatar Aug 05 '23 17:08 ghost

I don't see why we would be against this. You can open a PR. If any logic changes, make sure to add tests. Otherwise it sounds straight forward.

jensneuse avatar Aug 05 '23 19:08 jensneuse