fixed NodeInterfaceDefaultIsType

gql_cataclysm
noah metz 2023-07-31 20:12:06 -06:00
parent 3a53163f36
commit 47151905a0
1 changed files with 20 additions and 5 deletions

@ -25,19 +25,34 @@ func NewSingleton[K graphql.Type](init func() K, post_init func(K, *graphql.List
}
}
func NodeInterfaceDefaultIsType(extensions []ExtType) func(graphql.IsTypeOfParams) bool {
func NodeInterfaceDefaultIsType(required_extensions []ExtType) func(graphql.IsTypeOfParams) bool {
return func(p graphql.IsTypeOfParams) bool {
ctx, ok := p.Context.Value("resolve").(*ResolveContext)
if ok == false {
return false
}
node, ok := p.Value.(NodeResult)
if ok == false {
return false
}
for _, ext := range(extensions) {
_, has := node.Result.Extensions[ext]
if has == false {
node_type_def, exists := ctx.Context.Types[Hash(node.Result.NodeType)]
if exists == false {
return false
} else {
for _, ext := range(required_extensions) {
found := false
for _, e := range(node_type_def.Extensions) {
if e == ext {
found = true
break
}
}
if found == false {
return false
}
}
}
return true
}