Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.0k views
in Technique[技术] by (71.8m points)

nosql - How to accept array of same type in graphql scheema

I am working with faunadb and it allows me to upload a .gql file and rest is handeled by faunadb, my app is a todo list app, so I made the scheema for type Todo that can also contain array of Todo type, but when I use mutation createTodo like

mutation(
        $todo: String!,
        $description: String!,
        $status: Boolean!,
        $date:  String!,
        $id:  ID!,
        $priority: Priority,
        $subtodos: [Todo!],
        $comments: [String!],
        $reminders: [String!]
    ) {
    createTodo(data: {
        todo: $todo,
        description: $description,
        status: $status,
        date: $date,
        uid: $id,
        priority: $priority,
        subtodos: $subtodos,
        comments: $comments,
        reminders: $reminders 
     }) {
      todo
      date
      status
      _id
    }
}

And my graphql schema is

enum Priority {
  P1
  P2
  P3
  P4
}

type Todo {
  todo: String!
  description: String!
  status: Boolean!
  date: String!
  priority: Priority
  uid: ID!
  subtodos: [Todo!]
  comments: [String!]
  reminders: [String!]
}

type Query {
  allTodos: [Todo!]!
}

and error I am reciving is

Variable '$subtodos' cannot be non input type '[Todo!]'. (line 9, column 20): " + ' $subtodos: [Todo!],


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...