aws / aws/aws-appsync-community
selectionSetGraphQL is incomplete when using Fragments
- Dominant language
- HTML
- Stars
- 507
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
Currently, the `selectionSetGraphQL` field doe not give enough information about the selectionSet when Fragments are involved.
Example:
Schema:
```graphql
type Bar {
someField(someArg: String): String
}
type Foo {
bar: Bar
buzz: String
bizz: String
}
type Query {
foo(arg: String): Foo
}
schema {
query: Query
}
```
Query:
```graphql
query {
foo(arg: "hi") {
...FooFrag
bar {
...BarFrag
}
bizz
}
}
fragment FooFrag on Foo {
buzz
}
fragment BarFrag on Bar {
someField(someArg: "hello")
}
```
In the resolver for `foo`, `selectionSetGraphQL` contains:
```graphQL
{
...FooFrag
bar {
...BarFrag
}
bizz
}
```
There is no info about the `FooFrag` and `BarFrag` fragments.
The expected result should be either
```graphql
{
...FooFrag
bar {
...BarFrag
}
bizz
}
fragment FooFrag on Foo {
buzz
}
fragment BarFrag on Bar {
someField(someArg: "hello")
}
```
or be "resolved", like so:
```graphql
{
buzz
bar {
someField(someArg: "hello")
}
bizz
}
```
Alternatively, fragments could come in an extra `info` field (something like `$ctx.info.fragmentsGraphQL`)
The goal to that is to be able to grab the `someArg` value from the `someField` field. `selectionSetList` and `$ctx.args` don't contain that information.
Here, I would like to be able to use one single resolver for `foo` and resolve the full tree (I don't want an extra resolver for `someField` under `Bar`)
Hope that makes sense.
EDIT:
Another option would be to receive the FULL (top) query as a string. That way, we could just parse it and extract whatever we need. That would also allow other advanced usage.
Thanks!
Contributor guide
Research direction
The issue names no repository files, tests, or implementation entry points. Start by locating the resolver context and selectionSetGraphQL handling in the AppSync implementation, then determine which fragment behavior is intended; done means a documented behavior, implementation, and coverage for the supplied nested-fragment query.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, graphql
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100