Amplify-cli: handling nullable connections

Created on 22 Aug 2020  路  2Comments  路  Source: aws-amplify/amplify-cli

Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the
Amplify Console GitHub Issue Tracker

Describe the bug

I get an error "_All fields provided to an @connection must be non-null scalar or enum fields_".

Amplify CLI Version

@aws-amplify/[email protected]

To Reproduce

  1. Create models like so:
type ModelOne 
  @model {
  id: ID!
  testField: String
}

type ModelTwo
  @model {
  id: ID!
  testField2: String
  modelOneId: ID
  modelOne: @connection(fields: ["modelOneId"])
}

this will throw an error saying "_All fields provided to an @connection must be non-null scalar or enum fields_"

But when using the "old", and supposedly no longer recommended way of defining connections,

type ModelOne 
  @model {
  id: ID!
  testField: String
}

type ModelTwo
  @model {
  id: ID!
  testField2: String
  modelOneId: String
  modelOne: @connection(keyField: "modelOneId")
}

it works as I expected?

Expected behavior

Provide an option for nullable connection or turn the old and unrecommended way of doing it to be that option (? not really sure), the docs did not talk about this option.

Screenshots

N/A

Desktop (please complete the following information):

  • OS: N/A
  • Node Version: N/A

Additional context

N/A

@connection enhancement graphql-transformer review

Most helpful comment

@aprilmintacpineda This is an known behavior, I will mark this as enhancement, our team will review it.
@RossWilliams Thanks for your contribution, our team will review the PR.

All 2 comments

@aprilmintacpineda This is an known behavior, I will mark this as enhancement, our team will review it.
@RossWilliams Thanks for your contribution, our team will review the PR.

馃憤

Was this page helpful?
0 / 5 - 0 ratings