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

schema.graphql has incorrect duplicate relationships. #1044

Open
4 tasks done
qwikag opened this issue Sep 27, 2023 · 4 comments
Open
4 tasks done

schema.graphql has incorrect duplicate relationships. #1044

qwikag opened this issue Sep 27, 2023 · 4 comments
Labels
bug An issue which has been identified as a bug data Data modelling studio-ui An issue that needs to be tracked by Studio Console team

Comments

@qwikag
Copy link

qwikag commented Sep 27, 2023

Before opening, please confirm:

App Id

whyputappidinpublicforum

Region

ap-southeast-2

Environment name

develop

Figma File Version (if applicable)

N/A

Amplify CLI Version

No response

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

No response

What operating system are you using?

win10

Browser type?

chrome

Describe the bug

Cannot publish a new relationship with Pascal Case:
e.g.
type Person @model @auth(rules: [{allow: owner, operations: [read, update, create]}, {allow: private, operations: [create, read, update], provider: iam}]) {
id: ID!
Email: AWSEmail!
Username: AWSEmail
Firstname: String
Lastname: String
Mobile: AWSPhone
Birthdate: AWSDate
Address: String
Phone: AWSPhone
SystemLogs: [SystemLog] @hasmany(indexName: "byPerson", fields: ["id"])
Logins: [SystemLog] @hasmany(indexName: "byPerson", fields: ["id"])
Bookings: [Booking] @hasmany(indexName: "byPerson", fields: ["id"])
}

type Booking @model @auth(rules: [{allow: private, operations: [read]}, {allow: owner, operations: [create, read, update]}]) {
id: ID!
Name: String!
Start: AWSDateTime
Stop: AWSDateTime
OrgID: ID! @Index(name: "byOrganisation")
Status: String
OrganiserId: [Booking] @Index(name: "byPerson")
}

I get this error
DeploymentOrganiserId

Expected behavior

It should work just fine.

Reproduction steps

create parent child relationship with aand change the field name from
e.g. "personID" --> "PersonId"

Project Identifier

1d91fff5a13778a3f2da7571d70fa642

Additional information

NB: the duplicated SystemLog relationship on the Logins, is also very incorrect. It should be "Login".
I have multiple instances of this happening.
This too is a separate problem I am logging.

Amplify& AWS is hugely broken, and no longer worth getting involved in until these issues (and many more) get fixed.
I now have to take my business elsewhere.

AWS need to take a look at Salesforce and how successful their easy data modelling has been over the last 20years, seldom a failure.
And this is due to quality implementation of front end delivering on backend capability.

@qwikag
Copy link
Author

qwikag commented Sep 27, 2023

This is the schema that the docs say is the norm:

type Order @model {
  id: ID!
  customerID: ID! @index(name: "byCustomerByStatusByDate", sortKeyFields: ["status", "date"]) @index(name: "byCustomerByDate", sortKeyFields: ["date"])
  accountRepresentativeID: ID! @index(name: "byRepresentativebyDate", sortKeyFields: ["date"])
  productID: ID! @index(name: "byProduct", sortKeyFields: ["id"])
  status: String!
  amount: Int!
  date: String!
}

type Customer @model {
  id: ID!
  name: String!
  phoneNumber: String
  accountRepresentativeID: ID! @index(name: "byRepresentative", sortKeyFields: ["id"])
  ordersByDate: [Order] @hasMany(indexName: "byCustomerByDate", fields: ["id"])
  ordersByStatusDate: [Order] @hasMany(indexName: "byCustomerByStatusByDate", fields: ["id"])
}

type Employee @model {
  id: ID!
  name: String! @index(name: "byName", queryField: "employeeByName", sortKeyFields: ["id"])
  startDate: String!
  phoneNumber: String!
  warehouseID: ID! @index(name: "byWarehouse", sortKeyFields: ["id"])
  jobTitle: String! @index(name: "byTitle", queryField: "employeesByJobTitle", sortKeyFields: ["id"])
  newHire: String! @index(name: "newHire", queryField: "employeesNewHire", sortKeyFields: ["id"]) @index(name: "newHireByStartDate", queryField: "employeesNewHireByStartDate", sortKeyFields: ["startDate"])
}

type Warehouse @model {
  id: ID!
  employees: [Employee] @hasMany(indexName: "byWarehouse", fields: ["id"])
}

type AccountRepresentative @model {
  id: ID!
  customers: [Customer] @hasMany(indexName: "byRepresentative", fields: ["id"])
  orders: [Order] @hasMany(indexName: "byRepresentativebyDate", fields: ["id"])
  orderTotal: Int
  salesPeriod: String @index(name: "bySalesPeriodByOrderTotal", queryField: "repsByPeriodAndTotal", sortKeyFields: ["orderTotal"])
}

type Inventory @model {
  productID: ID! @primaryKey(sortKeyFields: ["warehouseID"])
  warehouseID: ID! @index(name: "byWarehouseID", queryField: "itemsByWarehouseID")
  inventoryAmount: Int!
}

type Product @model {
  id: ID!
  name: String!
  orders: [Order] @hasMany(indexName: "byProduct", fields: ["id"])
  inventories: [Inventory] @hasMany(fields: ["id"])
}

the difference with this from mine:

  1. lowerCamelCase
  2. byPerson should be "byPersonLogins" and "byPersonLogs"

It is highly likely the cli I picking up the double "byPerson" and causing a rewrite the the schema.

also the console is not helping by not enabling a write to these relationships and creating a duplicate "byPerson"

@ykethan
Copy link
Member

ykethan commented Sep 27, 2023

Hey @qwikag, thank you for reaching out. The error appears to be occurring due to OrganiserId: [Booking] @Index(name: "byPerson"). I was able to reproduce this issue using Amplify CLI. How is the relationship being created? could you provide us a screenshot of the models and its relationships in the data manager.

@ykethan ykethan added pending-response An issue is pending response from the issue requestor studio-ui An issue that needs to be tracked by Studio Console team data Data modelling labels Sep 27, 2023
@qwikag
Copy link
Author

qwikag commented Sep 27, 2023

Hi @ykethan,

Created in Amplify Studio (Setup --> Data)

Maybe update by cli???

Another example:
relationshipIncorrect

The problem here is the documentation about how to put together a good data-model, is weak, and needs a lot of work to communicate the idiosyncrasies.

I think console data modeling is broken, because that is where I started, and things have gone nasty.
but I will move to writing it in the schema.graphql, however the documentation is so Aweful.

@github-actions github-actions bot removed the pending-response An issue is pending response from the issue requestor label Sep 27, 2023
@ykethan
Copy link
Member

ykethan commented Oct 3, 2023

Hey @qwikag, I was able to reproduce the issue. Similar to #788 the visual editor creates a duplicate relationship.

Reproduction steps:

  1. Create models A, B, C
  2. add a oneToMany relationship from A to B
  3. Then add a oneToMany relationship from A to C
  4. Then change the oneToMany relationship from A to C -> A to B
  5. Then change the relationship back to A to C

The B models seems to have a duplicate relationship
image

Marking as bug.

I do agree the documentation could be improved to provide better information on creating a data modelling schema. Let pass this feedback to the team in improving the documentation. Thank you for taking the time in reaching out and providing this feedback.

@ykethan ykethan added bug An issue which has been identified as a bug and removed pending-triage An issue that is pending triage labels Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue which has been identified as a bug data Data modelling studio-ui An issue that needs to be tracked by Studio Console team
Projects
None yet
Development

No branches or pull requests

2 participants