Conversation
|
Something we’d highly recommend would be to have a migration path off the default resolver strategy that “figures out” what to do with an object. The decision tree has execution cost, although probably the bigger cost is in the upstream codebase where there are no consistency regulations for an object. For example, we have a prolific “Money” type that defines a value and currency. It gets resolved all over the place, except that some fields may resolve a formal Money object, others may resolve a hash of the relevant shape, etc. It’s a bit of a mess, and we realize now that it was the permissiveness of the default resolver that allowed us to be so sloppy. We have the same situation with lists where the engine permits anything that implements “each” as a list result, though this leads to frequent misuses where an each-able object is used as an array and results in error. |
|
Yes, agreed -- the new default behavior will be For the migration, it will flag implicit-resolve-behavior fields with a note that the default behavior is changing and the field can be migrated by:
|
In a lot of cases, GraphQL schema configurations can be automatically future-proofed. I'm hoping to write development utility to do this.
It will require moving some instance methods to class methods, and replacing the instance method body to a class method.
It would also be nice to have a clean-up method that removed the instance methods once they are unused
I think it will need access to the in-memory Schema definition. That would allow it to search for inherited methods.
hash_key:method:object.public_send(method_sym), it will work as written, no conversion requiredresolver_method:resolve_{each, batch, static}:class method. Calls methods on self or references to instance variables prevent auto-migration.resolve_eachmethod, but first choice is to have the owner audit the application and choose either hash key or method.resolver:,mutation:,subscription:extras:extensions:scope: trueandconnection: truein the gem?FutureStreamalso uses this. Can we useprependto intercept the method call? Field singleton classes have a dedicated::PreResolvemodule which contains these prepended methods? (This would create singleton classes for each field that uses it though, which is yuck, at least on old Ruby versions) Generate a method which calls theresolve_{each,batch,static}method?dig:connection:,scope:extensions:- not currently supportable but lots of possibilitiesdataload(...),dataload_record(...), anddataload_association(...)field :post, Types::PostType, dataload_assocation: true # or dataload_association: :post