-
Notifications
You must be signed in to change notification settings - Fork 7
/
example.go
75 lines (72 loc) · 2.59 KB
/
example.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
68
69
70
71
72
73
74
75
// This file was generated by github.com/EGT-Ukraine/go2gql. DO NOT EDIT IT
package schema
import (
interceptors "github.com/EGT-Ukraine/go2gql/api/interceptors"
example "github.com/EGT-Ukraine/go2gql/example/out/example"
proto "github.com/EGT-Ukraine/go2gql/example/proto"
graphql "github.com/graphql-go/graphql"
errors "github.com/pkg/errors"
)
type ExampleSchemaSchemaClients struct {
ServiceExampleClient proto.ServiceExampleClient
}
func (c ExampleSchemaSchemaClients) GetServiceExampleClient() proto.ServiceExampleClient {
return c.ServiceExampleClient
}
func GetExampleSchemaSchema(cls ExampleSchemaSchemaClients, ih *interceptors.InterceptorHandler) (graphql.Schema, error) {
if cls.ServiceExampleClient == nil {
return graphql.Schema{}, errors.Errorf("Service client ServiceExample can't be nil nil")
}
var ServiceExampleQueryFields = example.GetServiceExampleServiceQueryMethods(cls.ServiceExampleClient, ih)
var _ = ServiceExampleQueryFields
var ServiceExampleMutationFields = example.GetServiceExampleServiceMutationMethods(cls.ServiceExampleClient, ih)
var _ = ServiceExampleMutationFields
var Example = graphql.NewObject(graphql.ObjectConfig{
Name: "Example",
Description: "example result type",
Fields: graphql.Fields{
"getQueryMethod": ServiceExampleQueryFields["getQueryMethod"],
"queryMethod": ServiceExampleQueryFields["queryMethod"],
"getEmptiesMsg": ServiceExampleQueryFields["getEmptiesMsg"],
},
})
var Query = graphql.NewObject(graphql.ObjectConfig{
Name: "Query",
Fields: graphql.Fields{
"example": &graphql.Field{
Name: "example",
Type: Example,
Description: "Service, which do smth",
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
return struct{}{}, nil
},
},
},
})
var ExampleMutation = graphql.NewObject(graphql.ObjectConfig{
Name: "ExampleMutation",
Description: "example result type",
Fields: graphql.Fields{
"mutationMethod": ServiceExampleMutationFields["mutationMethod"],
"getMutatuionMethod": ServiceExampleMutationFields["getMutatuionMethod"],
"ListSomeEntities": ServiceExampleMutationFields["ListSomeEntities"],
},
})
var Mutation = graphql.NewObject(graphql.ObjectConfig{
Name: "Mutation",
Fields: graphql.Fields{
"example": &graphql.Field{
Name: "example",
Type: ExampleMutation,
Description: "Service, which do smth",
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
return struct{}{}, nil
},
},
},
})
return graphql.NewSchema(graphql.SchemaConfig{
Query: Query,
Mutation: Mutation,
})
}