I'm having trouble understanding why loads
on my graphql mutation isn't working (no object found for ...).
#4520
-
Hey Everyone. I'm working through the mutations documentation, trying to implement the autoload arguments functionally using
Here's my test mutation. It takes a user_id in, loads the user, and then returns the user.
What's interesting, is, I can get it to work by adding this method to the
Do I need to set object_from_id on every mutation? I may be misunderstanding what I need to do with this method. Anything else I should read up on in order to better understand why I can't load an object? I've created a test repo with my issue https://github.com/DennisMartinez/graphql_mutation_test. Documentation / issue reports I've read referenced in trying to understand this issue:
Additional notes
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi! Sorry for the trouble. By default, When you add How about updating |
Beta Was this translation helpful? Give feedback.
Hi! Sorry for the trouble. By default,
loads:
uses thedef self.object_from_id
method defined on your Schema, which is here:https://github.com/DennisMartinez/graphql_mutation_test/blob/86133c4adeb275a7d554a8a47bff12372ee15097/app/graphql/graphql_mutation_test_schema.rb#L38-L42
When you add
def object_from_id
to your mutation class, it overrides that method from the schema -- which is why it starts working again.How about updating
def self.object_from_id
in the schema definition? I think that would make it work the way you expect. Give it a try and let me know what you find!