Jghorton14
Jghorton14

Reputation: 754

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.

Upvotes: 0

Views: 64

Answers (1)

Michael Willingham
Michael Willingham

Reputation: 912

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:

Upvotes: 1

Related Questions