Search code examples
amazon-web-servicesgraphqlaws-appsync

Graphql Update Syntax issue with App sync


I am not familiar with appsync's syntax with graphql. I am trying to update one of my entities using app sync. I used Amazon's option to automatically allocate resources and connect them to DynamoDB. Here is my entity:

type Property {
  id: ID!
  address: String!
  listedDate: AWSDate!
  notes: String
  homeType: String!
  tenantName: String!
  ownerName: String!
  leaseExpDate: AWSDate!
}

Inside of my mutations, I have this:

type Mutation {
  updateProperty(input: UpdatePropertyInput!): Property
}

Along with this input:

input UpdatePropertyInput {
  id: ID!
  address: String
  listedDate: AWSDate
  notes: String
  homeType: String
  tenantName: String
  ownerName: String
  leaseExpDate: AWSDate
}

Here is my attempt at the mutation to update the given property:

mutation updateProperty {
    updateProperty(input: UpdatePropertyInput(id: 'myID')) {
      address: String!
    }
}

The closest implementation that I found in the appsync's docs can be found here.


Solution

  • Input objects are constructed using brackets like below:

    mutation updateProperty {
        updateProperty(input: {
          id: "myID",
          address: "myAddress"
        }) {
          address
        }
    }
    

    Here is some additional documentation on input objects can be found here: