如何创建数组数组作为ApolloGraphQL中的输入

问题描述 投票:0回答:1

如何在ApolloGraphQL中创建数组数组作为输入?

例如,像这样的查询的模式应该如何:

{
    Users(Id:1, Filters:[["a1","b1", "c1"], ["a2","b2","c2"]]) {
      Id
      Name
    }
}

我尝试了以下模式,但没有运气:

const typeDefs = gql`
  type Query{
      Users(
        Id: ID,
        Filters: [[String, String, String]]
      )
   }
 `;
graphql apollo apollo-client graphql-js apollo-server
1个回答
0
投票

嗨,安德,我也曾尝试实现类似的目标,但也没有走运。我最终改为使用对象列表:

const typeDefs = gql`
  type Query{
      Users(
        Id: ID,
        Filters: [Filter]
      )
  }

  input Filter{
    A: String!
    B: String!
    C: String!
  }
`;

结尾看起来像这样:

{
    Users(Id:1, Filters:[{A:"a1",B:"b1", C:"c1"}, ..]) {
      Id
      Name
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.