aws-samples / aws-samples/appsync-with-postgraphile-rds
[Bug] Lambda resolver doesn't work with any types of GraphQL fragments
- Dominant language
- PLpgSQL
- Stars
- 49
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
Hey,
I just wanted to highlight that as a huge limitation of the approach that you have, that because of this function in Lambda:
```typescript
function createGraphqlSource(event: AppSyncResolverEvent): string {
const fieldName = event.info.fieldName
const typeName = event.info.parentTypeName
let selectionSet = event.info.selectionSetGraphQL
if (typeName === 'Mutation' && event.stash.wrapper) {
selectionSet = `{${event.stash.wrapper} ${selectionSet}}`
}
const args = fieldToArgsMap[typeName + '.' + fieldName]
if (args) {
return `${typeName.toLowerCase()}(${args.op}) {\n ${fieldName}(${args.vars}) ${selectionSet}\n}`
}
return `${typeName.toLowerCase()} {\n ${fieldName} ${selectionSet}\n}`
}
```
The line: `let selectionSet = event.info.selectionSetGraphQL` means, that due to AppSync limitations, it won't include any normal or inline fragments in that. While normal fragments can be workaround by extracting that data from `event.info.electionSetList`, inline fragments are not included there as highlighted in that issue:
https://github.com/aws/aws-appsync-community/issues/142
I believe this should be highlighted in the README, that fragments are not supported with that example and inline fragments cannot be supported with this approach in general
Contributor guide
Assessment
This issue has not been assessed yet.