1package handler
2
3import (
4 "context"
5 "time"
6
7 "github.com/vektah/gqlgen/graphql"
8 "github.com/vektah/gqlgen/neelance/query"
9 "github.com/vektah/gqlgen/neelance/schema"
10)
11
12type executableSchemaStub struct {
13}
14
15var _ graphql.ExecutableSchema = &executableSchemaStub{}
16
17func (e *executableSchemaStub) Schema() *schema.Schema {
18 return schema.MustParse(`
19 schema { query: Query }
20 type Query { me: User! }
21 type User { name: String! }
22 `)
23}
24
25func (e *executableSchemaStub) Query(ctx context.Context, op *query.Operation) *graphql.Response {
26 return &graphql.Response{Data: []byte(`{"name":"test"}`)}
27}
28
29func (e *executableSchemaStub) Mutation(ctx context.Context, op *query.Operation) *graphql.Response {
30 return graphql.ErrorResponse(ctx, "mutations are not supported")
31}
32
33func (e *executableSchemaStub) Subscription(ctx context.Context, op *query.Operation) func() *graphql.Response {
34 return func() *graphql.Response {
35 time.Sleep(50 * time.Millisecond)
36 select {
37 case <-ctx.Done():
38 return nil
39 default:
40 return &graphql.Response{
41 Data: []byte(`{"name":"test"}`),
42 }
43 }
44 }
45}