本文整理汇总了Golang中github.com/rs/rest-layer/resource.Resource.GetResources方法的典型用法代码示例。如果您正苦于以下问题:Golang Resource.GetResources方法的具体用法?Golang Resource.GetResources怎么用?Golang Resource.GetResources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/rs/rest-layer/resource.Resource
的用法示例。
在下文中一共展示了Resource.GetResources方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addConnections
// addConnections adds connections fields to the object afterward to prevent from dead loops
func (t types) addConnections(o *graphql.Object, idx resource.Index, r *resource.Resource) {
// Add sub field references
for name, def := range r.Schema().Fields {
if ref, ok := def.Validator.(*schema.Reference); ok {
sr, found := idx.GetResource(ref.Path, nil)
if !found {
log.Panicf("resource reference not found: %s", ref.Path)
}
o.AddFieldConfig(name, &graphql.Field{
Description: def.Description,
Type: t.getObjectType(idx, sr),
Args: getFArgs(def.Params),
Resolve: getSubFieldResolver(name, sr, def),
})
}
}
// Add sub resources
for _, sr := range r.GetResources() {
name := sr.Name()
o.AddFieldConfig(name, &graphql.Field{
Description: fmt.Sprintf("Connection to %s", name),
Type: graphql.NewList(t.getObjectType(idx, sr)),
Args: listArgs,
Resolve: getSubResourceResolver(sr),
})
}
}