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

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

Open cookiejest opened this issue 1 year ago • 6 comments

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.

cookiejest avatar Aug 08 '24 19:08 cookiejest

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

ykethan avatar Aug 09 '24 15:08 ykethan

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

AnilMaktala avatar Aug 12 '24 18:08 AnilMaktala

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()])

cookiejest avatar Aug 13 '24 14:08 cookiejest

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

AnilMaktala avatar Aug 14 '24 20:08 AnilMaktala

"aws-amplify": "^6.4.3",
"@aws-amplify/backend": "^1.0.4",
"@aws-amplify/backend-cli": "^1.2.2",

cookiejest avatar Aug 14 '24 20:08 cookiejest

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

AnilMaktala avatar Aug 16 '24 18:08 AnilMaktala