Updated with graphql changed, need to make Self delete source of status on message received

gql_cataclysm
noah metz 2023-09-17 16:00:24 -06:00
parent 6bfe339854
commit 21224e8837
3 changed files with 3 additions and 16 deletions

@ -920,19 +920,6 @@ func NewGQLExtContext() *GQLExtContext {
}, },
}) })
// This library handles subscriptions by running the "Subscribe" function which should return a channel, and a "Resolve" function which returns the new value to send to the client
/*
Library modifications required:
1) Make the last result available in the ResolveContext
2) When resolving, check if the current field exists in the previous result, using the previous result instead of re-resolving(only resolve fields that don't exist in the previous result)
To make this work with graphvent:
1) In Subscribe:
- Make a channel for the gql extension to forward messages to this context
- Send the read request associated with the root of the subscription
2) In Resolve:
- If the incoming message is a read result, process it as the new root result
- If the incoming message is a status, delete all the nodes found from the root that have the same NodeID and re-resolve
*/
context.Subscription.AddFieldConfig("Self", &graphql.Field{ context.Subscription.AddFieldConfig("Self", &graphql.Field{
Type: context.NodeTypes[GQLNodeType], Type: context.NodeTypes[GQLNodeType],
Subscribe: func(p graphql.ResolveParams) (interface{}, error) { Subscribe: func(p graphql.ResolveParams) (interface{}, error) {
@ -964,7 +951,7 @@ func NewGQLExtContext() *GQLExtContext {
self_result = source self_result = source
ctx.Context.Log.Logf("gql", "FIRST_RESULT_RECEIVED") ctx.Context.Log.Logf("gql", "FIRST_RESULT_RECEIVED")
case StatusSignal: case StatusSignal:
// Look for Source in tree and delete references // Look for Source in p.Execution.LastResult and delete references
default: default:
return nil, fmt.Errorf("Don't know how to handle %+v", source) return nil, fmt.Errorf("Don't know how to handle %+v", source)
} }

@ -19,7 +19,7 @@ import (
) )
func TestGQLServer(t *testing.T) { func TestGQLServer(t *testing.T) {
ctx := logTestContext(t, []string{"test", "gql", "policy", "pending"}) ctx := logTestContext(t, []string{"test"})
TestNodeType := NewNodeType("TEST") TestNodeType := NewNodeType("TEST")
err := ctx.RegisterNodeType(TestNodeType, []ExtType{LockableExtType}) err := ctx.RegisterNodeType(TestNodeType, []ExtType{LockableExtType})

@ -1 +1 @@
Subproject commit 92a55bea55688b1f58df6ee4900def4d079fa237 Subproject commit dd82b0abca1e9a52fba07e8935da2164e2c3f565