本文整理匯總了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),
})
}
}