Wrong context to field resolver #4947
Replies: 4 comments 5 replies
-
Are you able to share code that reproduces this (ideally as a series of instructions starting with I'm not sure what you mean by a "query handler", FWIW. |
Beta Was this translation helpful? Give feedback.
-
@glasser Sorry for the delay. Finally winnowed this down to something manageable. Assuming I got this right in my quick and dirty hack-down, you should find that the hand-constructed AST in src/API.ts redefines the type Fire up GraphIQL and invoke the It's probably going to turn out that I've done something glaringly stupid, either in the setup for the call to Here is the repo |
Beta Was this translation helpful? Give feedback.
-
I’d agree, but I’ve looked (by hand) at the data structures in a debugger,
and they look okay. Do you know of any working examples that use
mergeSchemas?
…On Mon, Mar 1, 2021 at 2:59 PM David Glasser ***@***.***> wrote:
I'll try to set some time aside to investigate more deeply soon, but this
sure does seem like more of a graphql-tools issue than an apollo-server
issue (mergeSchemas comes from graphql-tools even though it is
re-exported by AS).
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4947 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQPXV7QQVMQSP4UEBZR5YNTTBQL6PANCNFSM4YBG2TQQ>
.
|
Beta Was this translation helpful? Give feedback.
-
Just to close this out, it was user error. I completely misunderstood what graphql-middleware actually does. The behavior I was seeing was actually correct. I now understand how to accomplish what I was trying to do, which is to provide a context generator to the ApolloServer() constructor. The one unfortunate part of this is that there doesn't seem to be any easy way to do different things to the context depending on the operation type. |
Beta Was this translation helpful? Give feedback.
-
I'm seeing a weird bug. I've got middleware applied in my server which adds fields to the context structure. If I breakpoint the query handler, I can see that the desired (modified) context is getting passed.
The return type on this query handler is [T!]. I have a field resolver on T.id. If I breakpoint this field resolver, the context that is passed is not the correct context. I have tested this on other fields with the same result.
Any idea why the context is not getting passed to the field resolver correctly? Things I should look for?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions