Passing Multiple Arguments to GraphQL Query

后端 未结 2 1607
遥遥无期
遥遥无期 2021-01-02 05:11

First thing

Appreciate this may be a bit of a stupid question, but I\'m working with GraphQL having come from the RDF/Linked Data world and having a

2条回答
  •  忘掉有多难
    2021-01-02 05:46

    First you need to extend you query by adding a "humans":

    extend type Query {
      humans(listId: [String!]): [Human!]
      human(id: ObjID!): Human
    }
    

    Second - write a resolver for it.

    Query: {
      humans(root, {listId}, { Human }) {
        return Human.fillAllByListId(listId);
      },
      ...
    },
    

    List of IDs could be passed as follows:

提交回复
热议问题