Passing Multiple Arguments to GraphQL Query

后端 未结 2 1580
遥遥无期
遥遥无期 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:

    0 讨论(0)
  • Whit Hasura you can do like this (IDK if that working only on Hasura)

    query getConfigurationList($ids: [String!]!) {
        configuration (where: {id:{_in: $ids}}){
            id
            value
        }
    }
    

    Here is the docs

    0 讨论(0)
提交回复
热议问题