2023-07-21 15:16:35 -06:00
|
|
|
package graphvent
|
|
|
|
import (
|
|
|
|
"github.com/graphql-go/graphql"
|
2023-07-29 11:03:41 -06:00
|
|
|
"github.com/graphql-go/graphql/language/ast"
|
2023-07-21 15:16:35 -06:00
|
|
|
)
|
|
|
|
|
2023-07-29 11:03:41 -06:00
|
|
|
func GetFieldNames(p graphql.ResolveParams) []string {
|
|
|
|
names := []string{}
|
|
|
|
|
|
|
|
for _, node := range(p.Info.FieldASTs) {
|
|
|
|
for _, sel := range(node.SelectionSet.Selections) {
|
|
|
|
names = append(names, sel.(*ast.Field).Name.Value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return names
|
|
|
|
}
|
|
|
|
|
|
|
|
var QueryNode = &graphql.Field{
|
|
|
|
Type: InterfaceNode.Interface,
|
|
|
|
Args: graphql.FieldConfigArgument{
|
|
|
|
"id": &graphql.ArgumentConfig{
|
|
|
|
Type: graphql.String,
|
|
|
|
},
|
|
|
|
},
|
2023-07-21 17:49:19 -06:00
|
|
|
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
|
2023-07-29 00:28:44 -06:00
|
|
|
ctx, err := PrepResolve(p)
|
2023-07-21 17:49:19 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-07-29 11:03:41 -06:00
|
|
|
ctx.Context.Log.Logf("gql", "FIELDS: %+v", GetFieldNames(p))
|
2023-07-29 00:28:44 -06:00
|
|
|
// Get a list of fields that will be written
|
|
|
|
// Send the read signal
|
|
|
|
// Wait for the response, returning an error on timeout
|
2023-07-21 15:16:35 -06:00
|
|
|
|
2023-07-29 00:28:44 -06:00
|
|
|
return nil, nil
|
2023-07-21 17:49:19 -06:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2023-07-29 11:03:41 -06:00
|
|
|
var QuerySelf = &graphql.Field{
|
|
|
|
Type: InterfaceNode.Default,
|
2023-07-21 17:49:19 -06:00
|
|
|
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
|
2023-07-29 11:03:41 -06:00
|
|
|
ctx, err := PrepResolve(p)
|
2023-07-21 17:49:19 -06:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-07-21 15:16:35 -06:00
|
|
|
|
2023-07-29 11:03:41 -06:00
|
|
|
ctx.Context.Log.Logf("gql", "FIELDS: %+v", GetFieldNames(p))
|
|
|
|
|
2023-07-29 00:28:44 -06:00
|
|
|
return nil, nil
|
2023-07-21 17:49:19 -06:00
|
|
|
},
|
2023-07-21 15:16:35 -06:00
|
|
|
}
|
2023-07-29 00:28:44 -06:00
|
|
|
|