Skip to content

Instantly share code, notes, and snippets.

@jaunesarmiento
Last active December 16, 2022 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaunesarmiento/00f9d6143437abe6d996872048c660a8 to your computer and use it in GitHub Desktop.
Save jaunesarmiento/00f9d6143437abe6d996872048c660a8 to your computer and use it in GitHub Desktop.
type Message
@model
@key(name: "byChannelID", fields: ["channelID", "createdAt"], queryField: "messagesByChannelID") {
id: ID!
channelID: ID!
author: String!
body: String!
createdAt: AWSDateTime
updatedAt: AWSDateTime
}
@mimoricom
Copy link

mimoricom commented Dec 14, 2021

I'm still on the way. From new amplify GraphQL Transformer version 2, @key directive is outdated, I modified your code like following then amplify push has passed.
`
type Message
@model {

id: ID!
channelID: ID! @Index(name: "byChannelID", sortKeyFields: ["createdAt"], queryField: "messagesByChannelID" )
author: String!
body: String!
createdAt: AWSDateTime
updatedAt: AWSDateTime
}
`

references
https://aws.amazon.com/blogs/mobile/aws-amplify-announces-the-new-graphql-transformer-v2-more-feature-rich-flexible-and-extensible/
https://docs.amplify.aws/cli/graphql/data-modeling/#configure-a-primary-key

@deepbodo
Copy link

I'm still on the way. From new amplify GraphQL Transformer version 2, @key directive is outdated, I modified your code like following then amplify push has passed. ` type Message @model {

id: ID! channelID: ID! @Index(name: "byChannelID", sortKeyFields: ["createdAt"], queryField: "messagesByChannelID" ) author: String! body: String! createdAt: AWSDateTime updatedAt: AWSDateTime } `

references https://aws.amazon.com/blogs/mobile/aws-amplify-announces-the-new-graphql-transformer-v2-more-feature-rich-flexible-and-extensible/ https://docs.amplify.aws/cli/graphql/data-modeling/#configure-a-primary-key
Thanks for the V2 code, was struggling to solve the doubt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment