...
1
2
3
4 package graphql
5
6 import (
7 "context"
8 "github.com/vektah/gqlparser/v2/ast"
9 "sync"
10 )
11
12
13
14 var _ ExecutableSchema = &ExecutableSchemaMock{}
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 type ExecutableSchemaMock struct {
38
39 ComplexityFunc func(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool)
40
41
42 ExecFunc func(ctx context.Context) ResponseHandler
43
44
45 SchemaFunc func() *ast.Schema
46
47
48 calls struct {
49
50 Complexity []struct {
51
52 TypeName string
53
54 FieldName string
55
56 ChildComplexity int
57
58 Args map[string]interface{}
59 }
60
61 Exec []struct {
62
63 Ctx context.Context
64 }
65
66 Schema []struct {
67 }
68 }
69 lockComplexity sync.RWMutex
70 lockExec sync.RWMutex
71 lockSchema sync.RWMutex
72 }
73
74
75 func (mock *ExecutableSchemaMock) Complexity(typeName string, fieldName string, childComplexity int, args map[string]interface{}) (int, bool) {
76 if mock.ComplexityFunc == nil {
77 panic("ExecutableSchemaMock.ComplexityFunc: method is nil but ExecutableSchema.Complexity was just called")
78 }
79 callInfo := struct {
80 TypeName string
81 FieldName string
82 ChildComplexity int
83 Args map[string]interface{}
84 }{
85 TypeName: typeName,
86 FieldName: fieldName,
87 ChildComplexity: childComplexity,
88 Args: args,
89 }
90 mock.lockComplexity.Lock()
91 mock.calls.Complexity = append(mock.calls.Complexity, callInfo)
92 mock.lockComplexity.Unlock()
93 return mock.ComplexityFunc(typeName, fieldName, childComplexity, args)
94 }
95
96
97
98
99
100 func (mock *ExecutableSchemaMock) ComplexityCalls() []struct {
101 TypeName string
102 FieldName string
103 ChildComplexity int
104 Args map[string]interface{}
105 } {
106 var calls []struct {
107 TypeName string
108 FieldName string
109 ChildComplexity int
110 Args map[string]interface{}
111 }
112 mock.lockComplexity.RLock()
113 calls = mock.calls.Complexity
114 mock.lockComplexity.RUnlock()
115 return calls
116 }
117
118
119 func (mock *ExecutableSchemaMock) Exec(ctx context.Context) ResponseHandler {
120 if mock.ExecFunc == nil {
121 panic("ExecutableSchemaMock.ExecFunc: method is nil but ExecutableSchema.Exec was just called")
122 }
123 callInfo := struct {
124 Ctx context.Context
125 }{
126 Ctx: ctx,
127 }
128 mock.lockExec.Lock()
129 mock.calls.Exec = append(mock.calls.Exec, callInfo)
130 mock.lockExec.Unlock()
131 return mock.ExecFunc(ctx)
132 }
133
134
135
136
137
138 func (mock *ExecutableSchemaMock) ExecCalls() []struct {
139 Ctx context.Context
140 } {
141 var calls []struct {
142 Ctx context.Context
143 }
144 mock.lockExec.RLock()
145 calls = mock.calls.Exec
146 mock.lockExec.RUnlock()
147 return calls
148 }
149
150
151 func (mock *ExecutableSchemaMock) Schema() *ast.Schema {
152 if mock.SchemaFunc == nil {
153 panic("ExecutableSchemaMock.SchemaFunc: method is nil but ExecutableSchema.Schema was just called")
154 }
155 callInfo := struct {
156 }{}
157 mock.lockSchema.Lock()
158 mock.calls.Schema = append(mock.calls.Schema, callInfo)
159 mock.lockSchema.Unlock()
160 return mock.SchemaFunc()
161 }
162
163
164
165
166
167 func (mock *ExecutableSchemaMock) SchemaCalls() []struct {
168 } {
169 var calls []struct {
170 }
171 mock.lockSchema.RLock()
172 calls = mock.calls.Schema
173 mock.lockSchema.RUnlock()
174 return calls
175 }
176
View as plain text