-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use extended instead of originals in after_resolve
Field Extensions let you extend (modify) the resolver object and arguments in the `resolve` hook. Previously the `after_resolve` hook would receive the *original* object and arguments and not the extended ones. This was a lossy process with no way for `after_resolve` to access the extended values. This changes `after_resolve` to receive the extended values instead. If you need access to the original non-extended values, the `memo` argument can be used. Example: ```ruby class MyExtension < GraphQL::Schema::FieldExtension def apply(field) field.argument(:my_new_arg, :string, required: false) end def resolve(object:, arguments:, context:) next_args = arguments.dup next_args.delete(:my_new_arg) yield(object, next_args, { original_arguments: arguments }) end def after_resolve(value:, context:, arguments:, memo:, **_args) # `arguments` => extended/modified arguments # `memo` => hash with `original_arguments` end end ```
- Loading branch information
1 parent
183f318
commit 53330be
Showing
3 changed files
with
46 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters