aws-amplify / amplify-category-api

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development. This plugin provides functionality for the API category, allowing for the creation and management of GraphQL and REST based backends for your amplify project.
https://docs.amplify.aws/
Apache License 2.0
89 stars 77 forks source link

best way to edit the generated graphql aws app sync schema in amplify v2? #2754

Open cookiejest opened 2 months ago

cookiejest commented 2 months ago

Environment information

I need to add additional fields into a few of the generated graphql schema endpoints. Speicfically the 'owner' field. This is so I can use them in the backend to correctly sync data to the front end via graphql.

What is the best way to achieve this? I can make the edits directly in appsync console, but feel there should be a way to do this through amplify v2 that I can keep within my ci/cd pipeline.

Description

E.g I want to add a 'owner' field that have not been added automatically for some reason (I think they should be):

input CreateMessageInput {
    type: String
    message: String
    color: String
    runId: ID
    promptId: ID
    id: ID
    owner: String
}

This way i can use the graphql directly from my backend outside of amplify and have it stay in sync with the amplify v2 on the real time updates.

ykethan commented 2 months ago

Hey👋 thanks for raising this! I'm going to transfer this over to our API repository for better assistance.

AnilMaktala commented 2 months ago

Hey @cookiejest, Thanks for raising this. Could you please share your full schema?

cookiejest commented 2 months ago

i think my problem is i did not include a owner field in the schema itself (I thought it would be auto populated but it was not). Once I added the field the owner the app sync was then correct with owner included.

  Message: a
    .model({
      type: a.string(),
      message: a.string(),
      color: a.string(),
      runId: a.id(),
      promptId: a.id(),
      owner: a.string(),
      run: a.belongsTo('Run', 'runId'),
      prompt: a.belongsTo('Prompt', 'promptId')
    })
    .authorization((allow) => [allow.owner()])
AnilMaktala commented 2 months ago

Hey @cookiejest, Thanks for clarifying. can you please provide the aws-amplify lib versions you are using in your app?

cookiejest commented 2 months ago
"aws-amplify": "^6.4.3",
"@aws-amplify/backend": "^1.0.4",
"@aws-amplify/backend-cli": "^1.2.2",
AnilMaktala commented 2 months ago

Hey @cookiejest, Thanks for additional information. We can reproduce the issue, Hence marking it as a bug for the team to evaluate further.

  Customer1: a
    .model({
      fullName: a.string(),
      email: a.email(),
      price: a.integer(),
      phone: a.phone(),
    })
    .authorization((allow) => [allow.owner()]),
image