boostercloud / booster

Booster Framework
https://www.boosterframework.com
Apache License 2.0
409 stars 83 forks source link

GraphQL Array<T> vs T[] inconsistencies #1017

Open MichaelHirn opened 2 years ago

MichaelHirn commented 2 years ago

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 error JSONObject cannot represent non-object value

✅ this works

export class OrdersByOwner {
  public constructor(
    public id: UUID,
    readonly orderIds: Array<UUID>
  ) {}

❌ this fails with above error when queried via GraphQL

export class OrdersByOwner {
  public constructor(
    public id: UUID,
    readonly orderIds: UUID[]
  ) {}

Expected behavior

Both Array<T> and T[] 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

Checklist - [X] ``packages/framework-core/src/library/graphql-adapter.ts`` ✅ Commit 8394c32 - [X] ``packages/framework-provider-aws/src/library/graphql-adapter.ts`` ⚠️ No Changes Made - [X] ``packages/framework-core/test/library/graphql-adapter.test.ts`` ✅ Commit f77b15e - [X] ``packages/framework-provider-aws/test/library/graphql-adapter.test.ts`` ✅ Commit 4fde026
sweep-ai[bot] commented 8 months ago

Here's the PR! https://github.com/boostercloud/booster/pull/1471.

⚡ Sweep Basic Tier: I'm creating this ticket using GPT-4. You have 4 GPT-4 tickets left for the month and 2 for the day. For more GPT-4 tickets, visit our payment portal.

Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I looked at (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/boostercloud/booster/blob/8c2328d75300c01a4487d4938a26072965481bb3/website/docs/03_architecture/06_read-model.mdx#L215-L325 https://github.com/boostercloud/booster/blob/8c2328d75300c01a4487d4938a26072965481bb3/packages/framework-integration-tests/integration/fixtures/read-models/cart-with-fields-read-model.ts#L1-L12 https://github.com/boostercloud/booster/blob/8c2328d75300c01a4487d4938a26072965481bb3/packages/framework-integration-tests/src/read-models/products-by-sku.ts#L1-L39 https://github.com/boostercloud/booster/blob/8c2328d75300c01a4487d4938a26072965481bb3/packages/framework-integration-tests/src/migrations/entities/Product/schema-versions.ts#L1-L17 https://github.com/boostercloud/booster/blob/8c2328d75300c01a4487d4938a26072965481bb3/packages/framework-integration-tests/integration/fixtures/read-models/cart-with-projection-read-model.ts#L1-L18

Step 2: ⌨️ Coding


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/fix-graphql-array-t-inconsistencies.

.


🎉 Latest improvements to Sweep:


💡 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