gpt4 book ai didi

go - "graphql.NewList(type)"是做什么的?

转载 作者:数据小太阳 更新时间:2023-10-29 03:09:21 27 4
gpt4 key购买 nike

事实证明,graphql-go的帮助文档对初学者不友好。我只是想知道 .NewList() 在以下代码中做了什么:Type: graphql.NewList(types.Workouts)

最佳答案

表示数组类型

Lists work in a similar way: We can use a type modifier to mark a type as a List, which indicates that this field will return an array of that type. In the schema language, this is denoted by wrapping the type in square brackets, [ and ].

// js
languages: {
type: new GraphQLNonNull(new GraphQLList(GraphQLString))
}

// schema language
languages: [String]! // returns empty array or array of strings

docs

关于go - "graphql.NewList(type)"是做什么的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54586002/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com