diff --git a/gql.go b/gql.go index 45a4f0d..18530f5 100644 --- a/gql.go +++ b/gql.go @@ -1098,15 +1098,9 @@ func NewGQLExtContext() *GQLExtContext { err = context.RegisterField(context.Interfaces["Node"].List, "Members", GroupExtType, "members", func(p graphql.ResolveParams, ctx *ResolveContext, value reflect.Value)(interface{}, error) { - node_map, ok := value.Interface().(map[NodeID]string) + node_list, ok := value.Interface().([]NodeID) if ok == false { - return nil, fmt.Errorf("value is %+v, not map[NodeID]string", value.Type()) - } - node_list := []NodeID{} - i := 0 - for id := range(node_map) { - node_list = append(node_list, id) - i += 1 + return nil, fmt.Errorf("value is %+v, not []NodeID", value.Type()) } nodes, err := ResolveNodes(ctx, p, node_list) diff --git a/gql_test.go b/gql_test.go index 4d4f63d..466da79 100644 --- a/gql_test.go +++ b/gql_test.go @@ -19,7 +19,7 @@ import ( ) func TestGQLServer(t *testing.T) { - ctx := logTestContext(t, []string{"test"}) + ctx := logTestContext(t, []string{"test", "gqlws"}) TestNodeType := NewNodeType("TEST") err := ctx.RegisterNodeType(TestNodeType, []ExtType{LockableExtType}) @@ -135,7 +135,7 @@ func TestGQLServer(t *testing.T) { ctx.Log.Logf("test", "RESP_2: %s", resp_2) sub_1 := GQLPayload{ - Query: "subscription { Self { ID, TypeHash, Requirements { ID }}}", + Query: "subscription { Self { ID, TypeHash, ... on Lockable { Requirements { ID }}}}", } SubGQL := func(payload GQLPayload) { @@ -149,9 +149,18 @@ func TestGQLServer(t *testing.T) { fatalErr(t, err) - init := GQLWSMsg{ - ID: uuid.New().String(), - Type: "connection_init", + type payload_struct struct { + Token string `json:"token"` + } + + init := struct{ + ID uuid.UUID `json:"id"` + Type string `json:"type"` + Payload payload_struct `json:"payload"` + }{ + uuid.New(), + "connection_init", + payload_struct{ auth_b64 }, } ser, err := json.Marshal(&init) @@ -194,6 +203,8 @@ func TestGQLServer(t *testing.T) { n, err = ws.Read(resp) fatalErr(t, err) ctx.Log.Logf("test", "SUB: %s", resp[:n]) + + // TODO: check that there are no more messages sent to ws within a timeout } SubGQL(sub_1)