amplify-category-api icon indicating copy to clipboard operation
amplify-category-api copied to clipboard

DataStore does not support 1 to 1 connection with both sides of connection as optional field

Open parvusville opened this issue 2 years ago • 2 comments

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

v14.21.3

Amplify CLI Version

11.0.5

What operating system are you using?

Pop Os

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

no.

Describe the bug

Our CI/CD fails with message DataStore does not support 1 to 1 connection with both sides of connection as optional field: AdditionalServicePricing.pricing. I have seen this error before too in CI/CD, but that time I also had a issue with package-lock and package.json being in desync, and after fixing that issue this Datastore message also stopped appearing. This message appears also if I run amplify codegen models. We don't use DataStore in this project.

We had many other issues affecting CI/CD, and after fixing them this error started to appear. We are using Transformer V1.

Looking at our build history, these have been failure reasons since the first error to now:

  1. New environment variable not set *Parameters: [xxx] must have values
  2. Non-model type pushed with @auth rules *Type ExecutionResult not found
  3. Non-model type pushed with @auth rules *Type CreatePricingsFromCsvResult not found
  4. Non-model type pushed with @auth rules *Type ExecutionResult not found
  5. DataStore does not support 1 to 1 connection with both sides of connection as optional field: AdditionalServicePricing.pricing

Below is the GraphQL schema. If I make AdditionalServicePricing pricing field non-mandatory, build in CI/CD goes through fine. Why does this happen, and why does this error start to show up seemingly out of nowhere? Also local amplify push goes through just fine also with pricing set to mandatory.

type Pricing
  @model
  @auth(
    rules: [
      { allow: private, provider: iam }
      { allow: groups, groupsField: "group" }
    ]
  )
  @key(
    name: "pricingByGroup"
    fields: ["group"]
    queryField: "pricingByGroup"
  ) {
  id: ID!
  name: String!
  group: String!
  elements: [PricingElement!]!
  useNextDayPrice: Boolean
  tax: Int
  _removed: String
}


type AdditionalServicePricing
  @model
  @auth(
    rules: [
      { allow: private, provider: iam }
      { allow: groups, groupsField: "group" }
    ]
  )
  @key(name: "byVehicle", fields: ["vehicleId"])
  @key(name: "byCategory", fields: ["categoryId"]) {
  id: ID!
  group: String!
  key: String!
  vehicleId: ID
  categoryId: ID
  pricingId: ID!
  pricing: Pricing! @connection(fields: ["pricingId"])
}

Expected behavior

The build should succeed with the same schema it has succeeded previously with. Or if it should not, why it has succeeded until now?

Reproduction steps

  1. Use the attached Schema
  2. Push and observe Amplify hosting CI/CD fail.

Project Identifier

f59e77335650fce92677ec2970143a9b

Log output

# Put your logs below this line


Additional information

CICD goes fine, if I make the @connection field in question optional.

Before submitting, please confirm:

  • [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • [X] I have removed any sensitive information from my code snippets and submission.

parvusville avatar Apr 25 '23 08:04 parvusville

@phani-srikar any updates on this?

I am still getting error for union type

@arealmaas did you find any solution on this

ManasaYugensys avatar Jul 26 '22 12:07 ManasaYugensys

Would love for y'all to create this functionality. It would seriously simply my scenarios in the future

ucheNkadiCode avatar Dec 11 '22 12:12 ucheNkadiCode