admin管理员组

文章数量:1122832

I'm defining my data model in the schema.graphql file for my Flutter app, seemingly without any syntax errors and following the rules of GraphQL v2, but then when I try to push the changes (amplify push) I get the following error: "id field is not of type Boolean".

A screenshot of my Terminal: The command "amplify push" has been entered, and the terminal returns the error "id field is not type Boolean"

I cannot for the life of me figure out why this is happening. I believe with GraphQL transformer v2 the id field should be type ID! as I've made it, but the error is suggesting that there's- what, a mismatch between the expected field type for the id field in one of my models?

I wish to push my changes to Amplify, but I cannot, until this error is solved.

Here's the code in question (aka the schema.graphql file), containing my three models:

type UserAuthInfo
  @model # In Amplify: Create a DynamoDB table and a GraphQL API for the model
  @auth(
    rules: [
      { allow: public, provider: identityPool, operations: [create] } # Allow public sign-up
      { allow: owner, operations: [read, update] } # Users can view & edit only their own records
      { allow: groups, groups: ["admin"], operations: [read, update, delete] } # Admins have full access
    ]
  ) {
  id: ID!
  email: AWSEmail!
  password: String!
  username: String!
}

# User model
type User
  @model
  @auth(
    rules: [
      { allow: owner, operations: [create, update, delete] } # Only the owner can create, update, or delete their user record
      { allow: groups, groups: ["admin"], operations: [create, update, delete] } # Admins can create, update, or delete any user record
    ]
  ) {
  id: ID!
  username: String! @index(name: "byUsername", queryField: "userByUsername")
  email: AWSEmail!
  # Challenges created by the user:
  challenges: [Challenge]
    @hasMany(
      indexName: "byOwner" # Matches the index name in the Challenge model, allows querying challenges by owner
      fields: ["id"]
    )
}

# Challenge model
type Challenge
  @model
  @auth(
    rules: [
      {
        allow: owner
        ownerField: "owner" # Use user ID for ownership tracking
        identityClaim: "sub" # Use the unique user ID (sub) from the identity provider
        operations: [create, update, delete]
      }
      { allow: groups, groups: ["admin"], operations: [create, update, delete] } # Allow admin to delete challenges
    ]
  ) {
  id: ID!
  title: String!
  lifeAspects: [String!]!
  details: String
  startDate: AWSDate!
  targetDate: AWSDate
  reminderDetails: String
  associatedGoalId: ID! # Goal linked to challenge, if any
  isCompleted: Boolean! # Tracks if the challenge is completed
  owner: ID! # ID of user who created the challenge
  createdAt: AWSDateTime # Automatically managed field for creation time
  isClosed: Boolean  # Tracks if the challenge is closed
    @index(
      name: "byOwner"
      queryField: "challengesByOwner" # Allows querying challenges by user's owner field
      sortKeyFields: ["createdAt"]
    )
}

Any help would be appreciated.

本文标签: flutterGraphQL schema file error quotid field is not of type BooleanquotStack Overflow