|
|
@ -85,13 +85,17 @@ func (ctx * Context) RegisterNodeType(def NodeDef) error {
|
|
|
|
|
|
|
|
|
|
|
|
ctx.Types[type_hash] = def
|
|
|
|
ctx.Types[type_hash] = def
|
|
|
|
|
|
|
|
|
|
|
|
if def.Reflect.Implements(ctx.GQL.NodeType) {
|
|
|
|
node_type := reflect.TypeOf((*Node)(nil)).Elem()
|
|
|
|
|
|
|
|
lockable_type := reflect.TypeOf((*Lockable)(nil)).Elem()
|
|
|
|
|
|
|
|
thread_type := reflect.TypeOf((*Thread)(nil)).Elem()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if def.Reflect.Implements(node_type) {
|
|
|
|
ctx.GQL.ValidNodes[def.Reflect] = def.GQLType
|
|
|
|
ctx.GQL.ValidNodes[def.Reflect] = def.GQLType
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if def.Reflect.Implements(ctx.GQL.LockableType) {
|
|
|
|
if def.Reflect.Implements(lockable_type) {
|
|
|
|
ctx.GQL.ValidLockables[def.Reflect] = def.GQLType
|
|
|
|
ctx.GQL.ValidLockables[def.Reflect] = def.GQLType
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if def.Reflect.Implements(ctx.GQL.ThreadType) {
|
|
|
|
if def.Reflect.Implements(thread_type) {
|
|
|
|
ctx.GQL.ValidThreads[def.Reflect] = def.GQLType
|
|
|
|
ctx.GQL.ValidThreads[def.Reflect] = def.GQLType
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ctx.GQL.TypeList = append(ctx.GQL.TypeList, def.GQLType)
|
|
|
|
ctx.GQL.TypeList = append(ctx.GQL.TypeList, def.GQLType)
|
|
|
@ -107,11 +111,6 @@ type GQLContext struct {
|
|
|
|
// Generated GQL schema
|
|
|
|
// Generated GQL schema
|
|
|
|
Schema graphql.Schema
|
|
|
|
Schema graphql.Schema
|
|
|
|
|
|
|
|
|
|
|
|
// Interface types to compare against
|
|
|
|
|
|
|
|
NodeType reflect.Type
|
|
|
|
|
|
|
|
LockableType reflect.Type
|
|
|
|
|
|
|
|
ThreadType reflect.Type
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// List of GQL types
|
|
|
|
// List of GQL types
|
|
|
|
TypeList []graphql.Type
|
|
|
|
TypeList []graphql.Type
|
|
|
|
|
|
|
|
|
|
|
@ -150,15 +149,14 @@ func NewGQLContext() GQLContext {
|
|
|
|
Schema: graphql.Schema{},
|
|
|
|
Schema: graphql.Schema{},
|
|
|
|
TypeList: []graphql.Type{},
|
|
|
|
TypeList: []graphql.Type{},
|
|
|
|
ValidNodes: ObjTypeMap{},
|
|
|
|
ValidNodes: ObjTypeMap{},
|
|
|
|
NodeType: reflect.TypeOf((*Node)(nil)).Elem(),
|
|
|
|
|
|
|
|
ValidThreads: ObjTypeMap{},
|
|
|
|
ValidThreads: ObjTypeMap{},
|
|
|
|
ThreadType: reflect.TypeOf((*Thread)(nil)).Elem(),
|
|
|
|
|
|
|
|
ValidLockables: ObjTypeMap{},
|
|
|
|
ValidLockables: ObjTypeMap{},
|
|
|
|
LockableType: reflect.TypeOf((*Lockable)(nil)).Elem(),
|
|
|
|
|
|
|
|
Query: query,
|
|
|
|
Query: query,
|
|
|
|
Mutation: mutation,
|
|
|
|
Mutation: mutation,
|
|
|
|
Subscription: subscription,
|
|
|
|
Subscription: subscription,
|
|
|
|
BaseNodeType: GQLTypeGraphNode.Type,
|
|
|
|
BaseNodeType: GQLTypeGraphNode.Type,
|
|
|
|
|
|
|
|
BaseLockableType: GQLTypeSimpleLockable.Type,
|
|
|
|
|
|
|
|
BaseThreadType: GQLTypeSimpleThread.Type,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return ctx
|
|
|
|
return ctx
|
|
|
|