-
Notifications
You must be signed in to change notification settings - Fork 219
feat(router): provide field arguments in operation context #2385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dkorittki
wants to merge
32
commits into
main
Choose a base branch
from
dominik/eng-8582-support-access-to-field-arguments-in-cosmo-streams-hooks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,015
−57
Open
Changes from 11 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
f6d76f5
feat: provide map of field arguments in operation context
dkorittki ec45e9e
chore: use a walker
dkorittki c9cc1e6
fix: only map arguments when needed
dkorittki 9bf3562
chore: clean up
dkorittki 8477e1a
chore: rename FieldArguments() to Arguments()
dkorittki c5d995f
chore: add unit tests
dkorittki 4800a8c
chore: improve godoc
dkorittki 130bd22
chore: add router tests
dkorittki 9f0c25f
chore: simplify Get method
dkorittki 08ca36e
Merge branch 'main' into dominik/eng-8582-support-access-to-field-arg…
dkorittki b28d9a7
chore: remove garbage, add comments
dkorittki a63ff06
fix: log a warning when value cant resolve
dkorittki d6fcf63
chore: add test verifying direct value resolving
dkorittki cdca088
chore: nil checks
dkorittki b9cbf97
fix: support aliased fields
dkorittki a14b7c4
fix: check report for errors
dkorittki 33d8dfc
chore: fix typo in comments
dkorittki 1c1490e
Merge branch 'main' into dominik/eng-8582-support-access-to-field-arg…
dkorittki 0766e76
chore: use custom type for field args
dkorittki 5dbc44a
feat: use engines field arg mapping
dkorittki 9395881
fix: avoid map creation during request processing
dkorittki 9f0e470
feat: populate option to disable field arg mapping
dkorittki b102472
chore: use corresponding graph-go-tools version
dkorittki 86ce4f7
Merge branch 'main'
dkorittki 72b7375
fix: prefix with mutation
dkorittki d8d667b
Merge branch 'main'
dkorittki c7fd52a
Merge branch 'main'
dkorittki ac1ecc9
fix: go mod tidy
dkorittki 9bf1f6a
chore: add inline fragment tests + refactor tests
dkorittki b68b33b
Merge branch 'main'
dkorittki 75244d3
Merge branch 'main' into dominik/eng-8582-support-access-to-field-arg…
dkorittki 4a28b25
chore: add test for asserting unknown paths
dkorittki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| package core | ||
|
|
||
| import "github.com/wundergraph/astjson" | ||
|
|
||
| // Arguments allow access to GraphQL field arguments used by clients. | ||
| type Arguments struct { | ||
| // First key is the path to the field in dot notation | ||
| // i.e. root_field.subfield1.subfield2. | ||
| // Second argument is the name of the argument of that field. | ||
| data map[string]map[string]*astjson.Value | ||
| } | ||
|
|
||
| // Get will return the value of argument a from field f. | ||
| // | ||
| // To access the an argument of a root level field, you need to pass the | ||
| // name of the field as the first argument to Get and the name of the argument | ||
| // as the second argument, e.g. Get("rootfield_name", "argument_name") . | ||
| // | ||
| // The field needs to be a dot notated path to the position of the field, | ||
| // if it is nested. | ||
| // For example you can access arg1 on field2 on the operation | ||
| // | ||
| // subscription { | ||
| // mySub(arg1: "val1", arg2: "val2") { | ||
| // field1 | ||
| // field2(arg1: "val3", arg2: "val4") | ||
| // } | ||
| // | ||
| // You need to call Get("mySub.field2", "arg1") . | ||
| // | ||
| // If f or a cannot be found nil is returned. | ||
| func (fa *Arguments) Get(f string, a string) *astjson.Value { | ||
| if fa == nil { | ||
| return nil | ||
| } | ||
|
|
||
| args, found := fa.data[f] | ||
| if !found { | ||
| return nil | ||
| } | ||
|
|
||
| return args[a] | ||
| } | ||
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.