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
When attempting to expose Mailjet::Resource in a GraphQL Type, the following exception is raised:
GraphQL::Backtrace::TracedError - UnhandlederrorduringGraphQLexecution:
FailedtoimplementMessageHistory.event_at,tried:
- `Types::ResourceTypes::MessageHistoryType#event_at`,whichdid not exist
- `Mailjet::Messagehistory#event_at`,whichdid not exist
- Lookinguphashkey`:event_at`or`"event_at"`on`#<Mailjet::Messagehistory:0x00005622b03ad6e8>`,butitwasn'taHashToimplementthisfield,defineoneofthemethodsabove(andcheckfortypos),orsupplya`fallback_value`.
Root cause:
The issue stems from GraphQL's field resolution mechanism. GraphQL checks if a field exists using .respond_to?(field). However, Mailjet uses method_missing to dynamically handle attribute access, which causes .respond_to?(field) to always return false.
Proposed solution:
To resolve this, Mailjet::Resource should implement .respond_to_missing?. This will ensure that .respond_to?(field) returns the correct value for dynamically generated attribute methods, allowing GraphQL to properly resolve fields on Mailjet resources.
I'll make a PR!
Thank you 🙂
The text was updated successfully, but these errors were encountered:
When attempting to expose Mailjet::Resource in a GraphQL Type, the following exception is raised:
Root cause:
The issue stems from GraphQL's field resolution mechanism. GraphQL checks if a field exists using .respond_to?(field). However, Mailjet uses method_missing to dynamically handle attribute access, which causes .respond_to?(field) to always return false.
Proposed solution:
To resolve this, Mailjet::Resource should implement .respond_to_missing?. This will ensure that .respond_to?(field) returns the correct value for dynamically generated attribute methods, allowing GraphQL to properly resolve fields on Mailjet resources.
I'll make a PR!
Thank you 🙂
The text was updated successfully, but these errors were encountered: