Open MichaelHirn opened 2 years ago
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
[X] packages/framework-core/src/library/graphql-adapter.ts
✅ Commit 8394c32
Create packages/framework-core/src/library/graphql-adapter.ts with contents:
• Locate the function that is responsible for transforming the read model fields to GraphQL fields.
• Add a condition to check if the field type is an array using `T[]` notation.
• If the field type is an array using `T[]` notation, transform it to `Array` notation before processing it further.
[X] packages/framework-provider-aws/src/library/graphql-adapter.ts
⚠️ No Changes Made
Modify packages/framework-provider-aws/src/library/graphql-adapter.ts with contents:
• Repeat the same steps as in `packages/framework-core/src/library/graphql-adapter.ts`.
[X] packages/framework-core/test/library/graphql-adapter.test.ts
✅ Commit f77b15e
Create packages/framework-core/test/library/graphql-adapter.test.ts with contents:
• Create a new test file for `graphql-adapter.ts` if it does not exist.
• Add a test case to verify that the GraphQL adapter can handle read models with `T[]` notation correctly.
• The test case should define a read model with a field using `T[]` notation, pass it to the GraphQL adapter, and assert that no errors are thrown and the output is as expected.
[X] packages/framework-provider-aws/test/library/graphql-adapter.test.ts
✅ Commit 4fde026
Modify packages/framework-provider-aws/test/library/graphql-adapter.test.ts with contents:
• Repeat the same steps as in `packages/framework-core/test/library/graphql-adapter.test.ts`.
I have finished reviewing the code for completeness. I did not find errors for sweep/fix-graphql-array-t-inconsistencies
.
.
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord
Bug Report
Current Behavior
A read model that uses
Array<T>
can be queried via GraphQL, while a read model that uses (the semantically identical notation)T[]
will throw the following GraphQL errorJSONObject cannot represent non-object value
✅ this works
❌ this fails with above error when queried via GraphQL
Expected behavior
Both
Array<T>
andT[]
to work and not throw any errors (I assume that in typescript both ways are semantically identical)Additional information
Potentially related/similar issues: #338, #436
Environment
@boostercloud/cli/0.24.2 darwin-x64 node-v14.18.1 (npm@6.14.15)
Checklist
- [X] ``packages/framework-core/src/library/graphql-adapter.ts`` ✅ Commit8394c32
- [X] ``packages/framework-provider-aws/src/library/graphql-adapter.ts`` ⚠️ No Changes Made - [X] ``packages/framework-core/test/library/graphql-adapter.test.ts`` ✅ Commitf77b15e
- [X] ``packages/framework-provider-aws/test/library/graphql-adapter.test.ts`` ✅ Commit4fde026