Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks done
oe-bayram opened this issue Apr 27, 2023 · 2 comments
Closed
3 tasks done

Comments

@oe-bayram
Copy link

Before opening, please confirm:

JavaScript Framework

React

Amplify APIs

GraphQL API

Amplify Categories

auth, storage, function, api

Environment information

# Put output below this line

  System:
    OS: Windows 10 10.0.19044
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 21.89 GB / 31.74 GB
  Binaries:
    Node: 18.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\ProgramData\npm\yarn.CMD
    npm: 9.5.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 113.0.5672.63
    Edge: Spartan (44.19041.1266.0), Chromium (112.0.1722.58)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @emotion/cache: ^11.10.3 => 11.10.3
    @emotion/react: ^11.10.0 => 11.10.0
    @emotion/styled: ^11.10.0 => 11.10.0
    @mui/material: ^5.10.2 => 5.10.2
    @mui/system: ^5.10.2 => 5.10.2
    @mui/x-date-pickers: ^5.0.1 => 5.0.1
    @sentry/cli: ^2.0.4 => 2.0.4
    @sentry/react: ^6.19.7 => 6.19.7
    @sentry/tracing: ^6.19.7 => 6.19.7
    @tanstack/react-table: ^8.5.30 => 8.5.30
    @trivago/prettier-plugin-sort-imports: ^3.4.0 => 3.4.0
    @types/draft-js: ^0.11.9 => 0.11.9
    @types/draftjs-to-html: ^0.8.1 => 0.8.1
    @types/lodash.isequal: ^4.5.5 => 4.5.5
    @types/node: ^16.11.27 => 16.11.27 (14.18.13)
    @types/react: ^18.0.5 => 18.0.5
    @types/react-bootstrap-table-next: ^4.0.17 => 4.0.17
    @types/react-dom: ^18.0.1 => 18.0.1
    @types/react-draft-wysiwyg: ^1.13.4 => 1.13.4
    @types/react-helmet: ^6.1.5 => 6.1.5
    @types/react-places-autocomplete: ^7.2.9 => 7.2.9
    @types/react-scroll: ^1.8.3 => 1.8.3
    @types/sortablejs: ^1.15.0 => 1.15.0
    @types/uuid: ^9.0.0 => 9.0.0
    aws-amplify: ^5.1.3 => 5.1.3
    date-fns: ^2.28.0 => 2.28.0
    draft-js: ^0.11.7 => 0.11.7
    draftjs-to-html: ^0.9.1 => 0.9.1
    exceljs: ^4.3.0 => 4.3.0
    graphql: ^16.3.0 => 16.3.0 (15.8.0)
    html-react-parser: ^1.4.11 => 1.4.11
    jspdf: ^2.5.1 => 2.5.1
    lodash.isequal: ^4.5.0 => 4.5.0
    moment: ^2.29.3 => 2.29.3
    moment-business-days: ^1.2.0 => 1.2.0
    nanoid: ^3.3.3 => 3.3.3
    notistack: ^2.0.4 => 2.0.4
    prettier: ^2.7.1 => 2.7.1
    react: ^18.0.0 => 18.0.0
    react-bootstrap-table-next: ^4.0.3 => 4.0.3
    react-dom: ^18.0.0 => 18.0.0
    react-draft-wysiwyg: ^1.14.7 => 1.14.7
    react-draggable: ^4.4.5 => 4.4.5
    react-dropzone: ^14.2.3 => 14.2.3
    react-helmet: ^6.1.0 => 6.1.0
    react-number-format: ^4.9.4 => 4.9.4
    react-places-autocomplete: ^7.3.0 => 7.3.0
    react-router-dom: ^6.3.0 => 6.3.0
    react-scripts: 5.0.1 => 5.0.1
    react-scroll: ^1.8.7 => 1.8.7
    react-select: ^5.7.0 => 5.7.0
    react-sortablejs: ^6.1.4 => 6.1.4
    react-use: ^17.3.2 => 17.3.2
    sortablejs: ^1.15.0 => 1.15.0
    tss-react: ^3.6.2 => 3.6.2
    typescript: ^4.6.3 => 4.6.3
    uuid: ^9.0.0 => 9.0.0 (3.4.0, 8.3.2)
    web-vitals: ^2.1.4 => 2.1.4
  npmGlobalPackages:
    @aws-amplify/cli: 10.4.1
    aws-es-kibana: 1.0.8
    corepack: 0.14.2
    create-next-app: 11.1.4
    create-react-app: 5.0.1
    gulp-cli: 2.3.0
    localtunnel: 2.0.2
    ts-node: 10.9.1
    typescript: 4.8.4

Describe the bug

We are working with a large schema that has deeply interconnected models and are using GraphQL Transformer v1. We have encountered the following issue:

DataStore does not support 1 to 1 connection with both sides of connection as optional field: Debit.invoice

We have removed this specific connection (Debit.invoice), but the issue seems to affect all other connections as well.

Interestingly, we do not use DataStore in our project, and Conflict Detection is disabled. We are not sure why this error is still appearing and causing problems.

type Debit  
  @model(subscriptions: null)
  @key(
    name: "debitsByInvoice"
    fields: ["invoiceID", "id"]
    queryField: "debitsByInvoice"
  )
  @auth(rules: [{ allow: owner }, { allow: groups, groups: ["Admin"] }]) {
  id: ID!
  datum: AWSDate!
  nettoBetrag: Float!
  referenzText: String!
  invoiceID: ID!
  invoice: Invoice! @connection(fields: ["invoiceID"])
}

type Invoice  # Rechnung
  @model(subscriptions: null)
  @searchable
  @key(
    name: "invoicesByCustomer"
    fields: ["customerID", "id"]
    queryField: "invoicesByCustomer"
  )
  @auth(rules: [{ allow: owner }, { allow: groups, groups: ["Admin"] }]) {
  id: ID!
  orderID: ID!
  order: Order! @connection(fields: ["orderID"])
  deliveryID: ID!
  delivery: Delivery! @connection(fields: ["deliveryID"])
  customerID: ID!
  customer: Customer! @connection(fields: ["customerID"])
  rechnungsNummer: String!
  mtz: Float!
  nettoPreis: Float!
  mwstSatz: Float!
  bruttoPreis: Float!
  datum: AWSDate!
  faelligkeitsDatum: AWSDate!
  gutschriftAbbuchungID: ID
  gutschriftAbbuchung: Debit @connection(fields: ["gutschriftAbbuchungID"])
}

Expected behavior

When not using DataStore in our project, we expect the schema to be processed without any issues related to the unsupported 1-to-1 connection. The error message should not appear, and the remaining connections should function as intended.

Reproduction steps

  1. Use the provided gql schema
  2. Push changes

Code Snippet

// Put your code below this line.

Log output

// Put your logs below this line


aws-exports.js

No response

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

@iartemiev
Copy link
Member

Hi @oe-bayram - if I'm reading this correctly, the error occurs in the GQL Transformer when you compile your Amplify schema, not at runtime. I'm transferring this issue to the team that manages the GQL Transformer library.

@iartemiev iartemiev transferred this issue from aws-amplify/amplify-js Apr 28, 2023
@oe-bayram
Copy link
Author

Yes, but this seems to be a known issue: 1419

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants