You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This isn't necessarily a bug, but I'd love to get your thoughts on the issue we're running into here!
For a GraphQL::Schema::Resolver, or GraphQL::Schema::Mutation argument, the proc set for prepare will get called before auto-loading happens when the loads argument is set.
But for a GraphQL::Schema::InputObject argument, the opposite appears to happen and the auto-loading happens first, followed by the the call to the prepare proc. In our case, we always want the prepare proc to be called first. I'll briefly cover why we need this in our case.
The initial build of our GraphQL API didn't return global IDs, but we do currently return global IDs. So apps can be sending us either global, or non-global IDs. When we receive a non-global ID we're actually still able to use the loads mechanism as we've added logic to the prepare proc that is able to convert the id into a global ID (we have meta-data configured on our types that allows us to convert it to the correct global ID format). This doesn't work for something that subclasses GraphQL::Schema::InputObject as the auto-loading happens first (and our proc wasn't able to convert it to global ID format first).
Would it be possible to update GraphQL::Schema::InputObject so the prepare is called before the auto-loading happens (if that is indeed the issue)? Or is there some other approach we should be considering here?
Versions
graphql version: 1.13
The text was updated successfully, but these errors were encountered:
Thanks for the detailed report. Dang, I hadn't noticed it before! But it makes sense to make it work the same way as Resolvers. I'll take a look soon and follow up here.
IIRC this code is a bit of a mess because of how resolvers are initialized: they're initialized during field resolution, but Input objects can be initialized earlier, since they're just a function of static type and AST/variable values. Since the object lifecycles are different, they use different mechanisms for these steps. It's confusing, and, evidently, out-of-order!
Describe the bug
This isn't necessarily a bug, but I'd love to get your thoughts on the issue we're running into here!
For a
GraphQL::Schema::Resolver
, orGraphQL::Schema::Mutation
argument, the proc set forprepare
will get called before auto-loading happens when theloads
argument is set.But for a
GraphQL::Schema::InputObject
argument, the opposite appears to happen and the auto-loading happens first, followed by the the call to the prepare proc. In our case, we always want the prepare proc to be called first. I'll briefly cover why we need this in our case.The initial build of our GraphQL API didn't return global IDs, but we do currently return global IDs. So apps can be sending us either global, or non-global IDs. When we receive a non-global ID we're actually still able to use the
loads
mechanism as we've added logic to theprepare
proc that is able to convert the id into a global ID (we have meta-data configured on our types that allows us to convert it to the correct global ID format). This doesn't work for something that subclassesGraphQL::Schema::InputObject
as the auto-loading happens first (and our proc wasn't able to convert it to global ID format first).Would it be possible to update
GraphQL::Schema::InputObject
so theprepare
is called before the auto-loading happens (if that is indeed the issue)? Or is there some other approach we should be considering here?Versions
graphql
version: 1.13The text was updated successfully, but these errors were encountered: