Alright,
GraphQL has input types that are separated from output or types for a reason.
However, in some cases, I want to build a query based on the returned values of a previous query.
Specifically, when calling
requestHealthPolicy(productCode: "HCP",
planInsurer: "SMJ", .... ){
status
policyNo}
I really want to wrap the parameters {productCode, etc}
into an input object which I can load from the database.
However, when I do the corresponding query i.e.
healthPlanByID(plan_id){
plan_type
plan_category
plan_provider{Provider{name}
}
}
I have some naming mismatch between the fields returned by the first query and the parameter fields required by the second query. Plus, some hirachy mismatches that need to be be cleaned up.
When the field names of the first and second query are all identical, I can create a different return type with a subset of the fields but because that type is an output type, I cannot pass it on as input type. Ok, that's a logical consequence of separating input from output types, but not exactly fun to work around.
Currently, the only way to do this, is effectively, casting the problem to the client by first loading, then matching fields, and then calling the requestHealthPolicy with the paramters previously extracted.
Practically, all I want is to pass the ID around and then, internally do the load, match, & call of the request query.
By that, I want to add a higher level of abstraction over the API in the sense of only asking for ID's from the public API endpoint, but underneath calling various
internal queries and mutations before returning the final result to the client. By that, I want to shield the client as much from internal (sensitive) data which aren't needed for the client request, but required for internal processing.
In other stacks, you simply write a bunch of functions that call existing queries and put them together as needed.
For some reason, I just cannot figure out how to implement that in the GradnStack with a custom resolver or similar.
Any ideas or pointers?