-
Notifications
You must be signed in to change notification settings - Fork 141
/
Copy pathstatic_datasource_test.go
67 lines (63 loc) · 1.53 KB
/
static_datasource_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package staticdatasource
import (
"testing"
"github.com/wundergraph/graphql-go-tools/pkg/engine/datasourcetesting"
"github.com/wundergraph/graphql-go-tools/pkg/engine/plan"
"github.com/wundergraph/graphql-go-tools/pkg/engine/resolve"
)
const (
definition = `type Query { hello: String }`
operation = `{ hello }`
)
func TestStaticDataSourcePlanning(t *testing.T) {
t.Run("simple", datasourcetesting.RunTest(definition, operation, "",
&plan.SynchronousResponsePlan{
Response: &resolve.GraphQLResponse{
Data: &resolve.Object{
Fields: []*resolve.Field{
{
BufferID: 0,
HasBuffer: true,
Name: []byte("hello"),
Value: &resolve.String{
Nullable: true,
},
},
},
Fetch: &resolve.SingleFetch{
BufferId: 0,
Input: "world",
DataSource: Source{},
DataSourceIdentifier: []byte("staticdatasource.Source"),
DisableDataLoader: true,
DisallowSingleFlight: true,
},
},
},
},
plan.Configuration{
DataSources: []plan.DataSourceConfiguration{
{
RootNodes: []plan.TypeField{
{
TypeName: "Query",
FieldNames: []string{"hello"},
},
},
Custom: ConfigJSON(Configuration{
Data: "world",
}),
Factory: &Factory{},
},
},
Fields: []plan.FieldConfiguration{
{
TypeName: "Query",
FieldName: "hello",
DisableDefaultMapping: true,
},
},
DisableResolveFieldPositions: true,
},
))
}