|
|
@ -27,28 +27,67 @@ func GQLVexQueries() map[string]*graphql.Field {
|
|
|
|
return queries
|
|
|
|
return queries
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func FindResources(event Event, resource_type reflect.Type) []Resource {
|
|
|
|
func GQLVexSubscriptions() map[string]*graphql.Field {
|
|
|
|
resources := event.RequiredResources()
|
|
|
|
subs := map[string]*graphql.Field{}
|
|
|
|
found := []Resource{}
|
|
|
|
subs["Arena"] = GQLVexSubscriptionArena()
|
|
|
|
for _, resource := range(resources) {
|
|
|
|
return subs
|
|
|
|
if reflect.TypeOf(resource) == resource_type {
|
|
|
|
}
|
|
|
|
found = append(found, resource)
|
|
|
|
|
|
|
|
|
|
|
|
var gql_vex_subscription_arena *graphql.Field = nil
|
|
|
|
|
|
|
|
func GQLVexSubscriptionArena() *graphql.Field {
|
|
|
|
|
|
|
|
if gql_vex_subscription_arena == nil {
|
|
|
|
|
|
|
|
gql_vex_subscription_arena = &graphql.Field{
|
|
|
|
|
|
|
|
Type: GQLVexTypeArena(),
|
|
|
|
|
|
|
|
Args: graphql.FieldConfigArgument{
|
|
|
|
|
|
|
|
"arena_id": &graphql.ArgumentConfig{
|
|
|
|
|
|
|
|
Type: graphql.String,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
|
|
|
|
|
|
|
|
return p.Source, nil
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
Subscribe: GQLVexSubscribeArena,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return gql_vex_subscription_arena
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, child := range(event.Children()) {
|
|
|
|
func GQLVexSubscribeArena(p graphql.ResolveParams)(interface{}, error) {
|
|
|
|
found = append(found, FindResources(child, resource_type)...)
|
|
|
|
server, ok := p.Context.Value("gql_server").(*GQLServer)
|
|
|
|
|
|
|
|
if ok == false {
|
|
|
|
|
|
|
|
return nil, fmt.Errorf("Failed to get gql_Server from context and cast to GQLServer")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m := map[string]Resource{}
|
|
|
|
c := make(chan interface{})
|
|
|
|
for _, resource := range(found) {
|
|
|
|
arena_id, ok := p.Args["arena_id"].(string)
|
|
|
|
m[resource.ID()] = resource
|
|
|
|
if ok == false {
|
|
|
|
|
|
|
|
return nil, fmt.Errorf("Failed to get arena_id arg")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
owner, ok := server.Owner().(Event)
|
|
|
|
|
|
|
|
if ok == false {
|
|
|
|
|
|
|
|
return nil, fmt.Errorf("Failed to cast owner to event")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ret := []Resource{}
|
|
|
|
resource := FindRequiredResource(owner, arena_id)
|
|
|
|
for _, resource := range(m) {
|
|
|
|
if resource == nil {
|
|
|
|
ret = append(ret, resource)
|
|
|
|
return nil, fmt.Errorf("Failed to find resource under owner")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
arena, ok := resource.(Arena)
|
|
|
|
|
|
|
|
if ok == false {
|
|
|
|
|
|
|
|
return nil, fmt.Errorf("Failed to cast resource to arena")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sig_c := arena.UpdateChannel()
|
|
|
|
|
|
|
|
go func(c chan interface{}, sig_c chan GraphSignal, arena Arena) {
|
|
|
|
|
|
|
|
c <- arena
|
|
|
|
|
|
|
|
for {
|
|
|
|
|
|
|
|
_, ok := <- sig_c
|
|
|
|
|
|
|
|
if ok == false {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
c <- arena
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}(c, sig_c, arena)
|
|
|
|
|
|
|
|
return c, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var gql_vex_mutation_set_match_state *graphql.Field= nil
|
|
|
|
var gql_vex_mutation_set_match_state *graphql.Field= nil
|
|
|
|