@ -7,12 +7,12 @@ import (
)
var gql_interface_graph_node * graphql . Interface = nil
func GQLInterface Graph Node( ) * graphql . Interface {
func GQLInterface Node( ) * graphql . Interface {
if gql_interface_graph_node == nil {
gql_interface_graph_node = graphql . NewInterface ( graphql . InterfaceConfig {
Name : " Graph Node",
Name : " Node",
ResolveType : func ( p graphql . ResolveTypeParams ) * graphql . Object {
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
return nil
}
@ -39,10 +39,6 @@ func GQLInterfaceGraphNode() *graphql.Interface {
gql_interface_graph_node . AddFieldConfig ( "ID" , & graphql . Field {
Type : graphql . String ,
} )
gql_interface_graph_node . AddFieldConfig ( "Name" , & graphql . Field {
Type : graphql . String ,
} )
}
return gql_interface_graph_node
@ -62,7 +58,7 @@ func GQLInterfaceThread() *graphql.Interface {
gql_interface_thread = graphql . NewInterface ( graphql . InterfaceConfig {
Name : "Thread" ,
ResolveType : func ( p graphql . ResolveTypeParams ) * graphql . Object {
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
return nil
}
@ -133,7 +129,7 @@ func GQLInterfaceLockable() *graphql.Interface {
gql_interface_lockable = graphql . NewInterface ( graphql . InterfaceConfig {
Name : "Lockable" ,
ResolveType : func ( p graphql . ResolveTypeParams ) * graphql . Object {
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
return nil
}
@ -186,27 +182,27 @@ func GQLInterfaceLockable() *graphql.Interface {
}
func GQLNodeID ( p graphql . ResolveParams ) ( interface { } , error ) {
node , ok := p . Source . ( Graph Node)
node , ok := p . Source . ( Node)
if ok == false || node == nil {
return nil , fmt . Errorf ( "Failed to cast source to Graph Node")
return nil , fmt . Errorf ( "Failed to cast source to Node")
}
return node . ID ( ) , nil
}
func GQL NodeName ( p graphql . ResolveParams ) ( interface { } , error ) {
node , ok := p . Source . ( G raphNo de )
func GQL ThreadListen ( p graphql . ResolveParams ) ( interface { } , error ) {
node , ok := p . Source . ( * G QLTh re ad)
if ok == false || node == nil {
return nil , fmt . Errorf ( "Failed to cast source to G raphNo de ")
return nil , fmt . Errorf ( "Failed to cast source to G QLTh re ad")
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Graph Context")
return nil , fmt . Errorf ( "Failed to cast context graph_context to Context")
}
name := ""
err := UseStates ( ctx , [ ] Graph Node{ node } , func ( states NodeStat eMap) ( error ) {
name = states [ node . ID ( ) ] . Name ( )
listen := ""
err := UseStates ( ctx , [ ] Node{ node } , func ( nodes Nod eMap) ( error ) {
listen = node . Listen
return nil
} )
@ -214,27 +210,23 @@ func GQLNodeName(p graphql.ResolveParams) (interface{}, error) {
return nil , err
}
return name , nil
return listen , nil
}
func GQLThread Listen ( p graphql . ResolveParams ) ( interface { } , error ) {
node , ok := p . Source . ( * GQL Thread)
func GQLThread Parent ( p graphql . ResolveParams ) ( interface { } , error ) {
node , ok := p . Source . ( Thread)
if ok == false || node == nil {
return nil , fmt . Errorf ( "Failed to cast source to GQL Thread")
return nil , fmt . Errorf ( "Failed to cast source to Thread")
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Graph Context")
return nil , fmt . Errorf ( "Failed to cast context graph_context to Context")
}
listen := ""
err := UseStates ( ctx , [ ] GraphNode { node } , func ( states NodeStateMap ) ( error ) {
gql_thread , ok := states [ node . ID ( ) ] . ( * GQLThreadState )
if ok == false {
return fmt . Errorf ( "Failed to cast state to GQLThreadState" )
}
listen = gql_thread . Listen
var parent Thread = nil
err := UseStates ( ctx , [ ] Node { node } , func ( nodes NodeMap ) ( error ) {
parent = node . Parent ( )
return nil
} )
@ -242,27 +234,23 @@ func GQLThreadListen(p graphql.ResolveParams) (interface{}, error) {
return nil , err
}
return listen , nil
return parent , nil
}
func GQLThread Parent ( p graphql . ResolveParams ) ( interface { } , error ) {
func GQLThread Children ( p graphql . ResolveParams ) ( interface { } , error ) {
node , ok := p . Source . ( Thread )
if ok == false || node == nil {
return nil , fmt . Errorf ( "Failed to cast source to Thread" )
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Graph Context")
return nil , fmt . Errorf ( "Failed to cast context graph_context to Context")
}
var parent Thread = nil
err := UseStates ( ctx , [ ] GraphNode { node } , func ( states NodeStateMap ) ( error ) {
gql_thread , ok := states [ node . ID ( ) ] . ( ThreadState )
if ok == false {
return fmt . Errorf ( "Failed to cast state to ThreadState" )
}
parent = gql_thread . Parent ( )
var children [ ] Thread = nil
err := UseStates ( ctx , [ ] Node { node } , func ( nodes NodeMap ) ( error ) {
children = node . Children ( )
return nil
} )
@ -270,27 +258,23 @@ func GQLThreadParent(p graphql.ResolveParams) (interface{}, error) {
return nil , err
}
return parent , nil
return children , nil
}
func GQL ThreadChildren ( p graphql . ResolveParams ) ( interface { } , error ) {
node , ok := p . Source . ( Thread )
func GQL LockableName ( p graphql . ResolveParams ) ( interface { } , error ) {
node , ok := p . Source . ( Lockable )
if ok == false || node == nil {
return nil , fmt . Errorf ( "Failed to cast source to Thread ")
return nil , fmt . Errorf ( "Failed to cast source to Lockable ")
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
if ok == false {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Graph Context")
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false || node == nil {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Context")
}
var children [ ] Thread = nil
err := UseStates ( ctx , [ ] GraphNode { node } , func ( states NodeStateMap ) ( error ) {
gql_thread , ok := states [ node . ID ( ) ] . ( ThreadState )
if ok == false {
return fmt . Errorf ( "Failed to cast state to ThreadState" )
}
children = gql_thread . Children ( )
name := ""
err := UseStates ( ctx , [ ] Node { node } , func ( nodes NodeMap ) error {
name = node . Name ( )
return nil
} )
@ -298,7 +282,7 @@ func GQLThreadChildren(p graphql.ResolveParams) (interface{}, error) {
return nil , err
}
return children , nil
return name , nil
}
func GQLLockableRequirements ( p graphql . ResolveParams ) ( interface { } , error ) {
@ -307,18 +291,14 @@ func GQLLockableRequirements(p graphql.ResolveParams) (interface{}, error) {
return nil , fmt . Errorf ( "Failed to cast source to Lockable" )
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Graph Context")
return nil , fmt . Errorf ( "Failed to cast context graph_context to Context")
}
var requirements [ ] Lockable = nil
err := UseStates ( ctx , [ ] GraphNode { node } , func ( states NodeStateMap ) ( error ) {
gql_thread , ok := states [ node . ID ( ) ] . ( LockableState )
if ok == false {
return fmt . Errorf ( "Failed to cast state to LockableState" )
}
requirements = gql_thread . Requirements ( )
err := UseStates ( ctx , [ ] Node { node } , func ( nodes NodeMap ) ( error ) {
requirements = node . Requirements ( )
return nil
} )
@ -335,18 +315,14 @@ func GQLLockableDependencies(p graphql.ResolveParams) (interface{}, error) {
return nil , fmt . Errorf ( "Failed to cast source to Lockable" )
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Graph Context")
return nil , fmt . Errorf ( "Failed to cast context graph_context to Context")
}
var dependencies [ ] Lockable = nil
err := UseStates ( ctx , [ ] GraphNode { node } , func ( states NodeStateMap ) ( error ) {
gql_thread , ok := states [ node . ID ( ) ] . ( LockableState )
if ok == false {
return fmt . Errorf ( "Failed to cast state to LockableState" )
}
dependencies = gql_thread . Dependencies ( )
err := UseStates ( ctx , [ ] Node { node } , func ( nodes NodeMap ) ( error ) {
dependencies = node . Dependencies ( )
return nil
} )
@ -363,18 +339,14 @@ func GQLLockableOwner(p graphql.ResolveParams) (interface{}, error) {
return nil , fmt . Errorf ( "Failed to cast source to Lockable" )
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Graph Context")
return nil , fmt . Errorf ( "Failed to cast context graph_context to Context")
}
var owner GraphNode = nil
err := UseStates ( ctx , [ ] GraphNode { node } , func ( states NodeStateMap ) ( error ) {
gql_thread , ok := states [ node . ID ( ) ] . ( LockableState )
if ok == false {
return fmt . Errorf ( "Failed to cast state to LockableState" )
}
owner = gql_thread . Owner ( )
var owner Node = nil
err := UseStates ( ctx , [ ] Node { node } , func ( nodes NodeMap ) ( error ) {
owner = node . Owner ( )
return nil
} )
@ -392,7 +364,7 @@ func GQLTypeGQLThread() * graphql.Object {
gql_type_gql_thread = graphql . NewObject ( graphql . ObjectConfig {
Name : "GQLThread" ,
Interfaces : [ ] * graphql . Interface {
GQLInterface Graph Node( ) ,
GQLInterface Node( ) ,
GQLInterfaceThread ( ) ,
GQLInterfaceLockable ( ) ,
} ,
@ -410,7 +382,7 @@ func GQLTypeGQLThread() * graphql.Object {
gql_type_gql_thread . AddFieldConfig ( "Name" , & graphql . Field {
Type : graphql . String ,
Resolve : GQL Nod eName,
Resolve : GQL Lockabl eName,
} )
gql_type_gql_thread . AddFieldConfig ( "Children" , & graphql . Field {
@ -452,12 +424,12 @@ func GQLTypeBaseThread() * graphql.Object {
gql_type_base_thread = graphql . NewObject ( graphql . ObjectConfig {
Name : "BaseThread" ,
Interfaces : [ ] * graphql . Interface {
GQLInterface Graph Node( ) ,
GQLInterface Node( ) ,
GQLInterfaceThread ( ) ,
GQLInterfaceLockable ( ) ,
} ,
IsTypeOf : func ( p graphql . IsTypeOfParams ) bool {
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
return false
}
@ -481,7 +453,7 @@ func GQLTypeBaseThread() * graphql.Object {
gql_type_base_thread . AddFieldConfig ( "Name" , & graphql . Field {
Type : graphql . String ,
Resolve : GQL Nod eName,
Resolve : GQL Lockabl eName,
} )
gql_type_base_thread . AddFieldConfig ( "Children" , & graphql . Field {
@ -518,11 +490,11 @@ func GQLTypeBaseLockable() * graphql.Object {
gql_type_base_lockable = graphql . NewObject ( graphql . ObjectConfig {
Name : "BaseLockable" ,
Interfaces : [ ] * graphql . Interface {
GQLInterface Graph Node( ) ,
GQLInterface Node( ) ,
GQLInterfaceLockable ( ) ,
} ,
IsTypeOf : func ( p graphql . IsTypeOfParams ) bool {
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
return false
}
@ -546,7 +518,7 @@ func GQLTypeBaseLockable() * graphql.Object {
gql_type_base_lockable . AddFieldConfig ( "Name" , & graphql . Field {
Type : graphql . String ,
Resolve : GQL Nod eName,
Resolve : GQL Lockabl eName,
} )
gql_type_base_lockable . AddFieldConfig ( "Requirements" , & graphql . Field {
@ -573,10 +545,10 @@ func GQLTypeBaseNode() * graphql.Object {
gql_type_base_node = graphql . NewObject ( graphql . ObjectConfig {
Name : "BaseNode" ,
Interfaces : [ ] * graphql . Interface {
GQLInterface Graph Node( ) ,
GQLInterface Node( ) ,
} ,
IsTypeOf : func ( p graphql . IsTypeOfParams ) bool {
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
return false
}
@ -600,7 +572,7 @@ func GQLTypeBaseNode() * graphql.Object {
gql_type_base_node . AddFieldConfig ( "Name" , & graphql . Field {
Type : graphql . String ,
Resolve : GQL Nod eName,
Resolve : GQL Lockabl eName,
} )
}
@ -699,32 +671,32 @@ func GQLTypeSignalInput() *graphql.InputObject {
}
func GQLSubscribeSignal ( p graphql . ResolveParams ) ( interface { } , error ) {
return GQLSubscribeFn ( p , false , func ( ctx * Graph Context, server * GQLThread , signal GraphSignal , p graphql . ResolveParams ) ( interface { } , error ) {
return GQLSubscribeFn ( p , false , func ( ctx * Context, server * GQLThread , signal GraphSignal , p graphql . ResolveParams ) ( interface { } , error ) {
return signal , nil
} )
}
func GQLSubscribeSelf ( p graphql . ResolveParams ) ( interface { } , error ) {
return GQLSubscribeFn ( p , true , func ( ctx * Graph Context, server * GQLThread , signal GraphSignal , p graphql . ResolveParams ) ( interface { } , error ) {
return GQLSubscribeFn ( p , true , func ( ctx * Context, server * GQLThread , signal GraphSignal , p graphql . ResolveParams ) ( interface { } , error ) {
return server , nil
} )
}
func GQLSubscribeFn ( p graphql . ResolveParams , send_nil bool , fn func ( * Graph Context, * GQLThread , GraphSignal , graphql . ResolveParams ) ( interface { } , error ) ) ( interface { } , error ) {
func GQLSubscribeFn ( p graphql . ResolveParams , send_nil bool , fn func ( * Context, * GQLThread , GraphSignal , graphql . ResolveParams ) ( interface { } , error ) ) ( interface { } , error ) {
server , ok := p . Context . Value ( "gql_server" ) . ( * GQLThread )
if ok == false {
return nil , fmt . Errorf ( "Failed to get gql_server from context and cast to GQLServer" )
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
return nil , fmt . Errorf ( "Failed to get graph_context from context and cast to Graph Context")
return nil , fmt . Errorf ( "Failed to get graph_context from context and cast to Context")
}
c := make ( chan interface { } )
go func ( c chan interface { } , server * GQLThread ) {
ctx . Log . Logf ( "gqlws" , "GQL_SUBSCRIBE_THREAD_START" )
sig_c := server . UpdateChannel ( 1 )
sig_c := UpdateChannel ( server , 1 , RandID ( ) )
if send_nil == true {
sig_c <- nil
}
@ -793,9 +765,9 @@ func GQLMutationSendUpdate() *graphql.Field {
return nil , fmt . Errorf ( "Failed to cast context gql_server to GQLServer: %+v" , p . Context . Value ( "gql_server" ) )
}
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Graph Context)
ctx , ok := p . Context . Value ( "graph_context" ) . ( * Context)
if ok == false {
return nil , fmt . Errorf ( "Failed to cast context graph_context to Graph Context: %+v", p . Context . Value ( "graph_context" ) )
return nil , fmt . Errorf ( "Failed to cast context graph_context to Context: %+v", p . Context . Value ( "graph_context" ) )
}
signal_map , ok := p . Args [ "signal" ] . ( map [ string ] interface { } )
@ -818,13 +790,13 @@ func GQLMutationSendUpdate() *graphql.Field {
return nil , fmt . Errorf ( "Failed to cast arg id to string" )
}
var node Graph Node = nil
err := UseStates ( ctx , [ ] Graph Node{ server } , func ( states NodeStat eMap) ( error ) {
node = FindChild ( ctx , server , NodeID ( id ) , stat es)
var node Node = nil
err := UseStates ( ctx , [ ] Node{ server } , func ( nodes Nod eMap) ( error ) {
node = FindChild ( ctx , server , NodeID ( id ) , nod es)
if node == nil {
return fmt . Errorf ( "Failed to find ID: %s as child of server thread" , id )
}
SendUpdate ( ctx , node , signal , stat es)
node . Signal ( ctx , signal , nod es)
return nil
} )
if err != nil {