Open asaf opened 5 years ago
Can you give a code example please?
lets say I have a custom object I want to return in resolvers:
type CustomObject struct {
attrs map[string]interface{}
}
func (c *CustomObject) Get(key string) interface{} {
return c.attrs[key]
}
DefaultResolveFn
won't be able to resolve such an object because it's not a plain map nor a struct, i need a custom resolver to invoke obj.Get(key)
and since I can't add Resolve
func on the CustomObject level (it's an external package) I need to provide a default custom resolver.
Thanks.
I have a another use case were I like to have my own DefaultResolveFn
I want to modify the DefaultResolveFn
in a way that it dereferences pointer properties on my model.
Else I always end up with a lot of boilerplate in my ObjectConfig.Fields
:
"deviceType": &Field{
Type: deviceTypeType,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
return *p.Source.(model.Hardware).DeviceType, nil
},
},
Or is that generally a bad Idea?
Hey,
I have a custom type system and i have few constraints:
Unless there's a better approach, I would like to provide a custom
DefaultResolveFn
.Thanks.