|
72 | 72 | ---
|
73 | 73 | --- @treturn table result of the operation
|
74 | 74 | local function compile_and_execute(state, query, variables, operation_name,
|
75 |
| - opts) |
| 75 | + compile_opts) |
76 | 76 | assert(type(state) == 'table', 'use :compile_and_execute(...) ' ..
|
77 | 77 | 'instead of .compile_and_execute(...)')
|
78 | 78 | assert(state.schema ~= nil, 'have not compiled schema')
|
79 | 79 | check(query, 'query', 'string')
|
80 | 80 | check(variables, 'variables', 'table', 'nil')
|
81 | 81 | check(operation_name, 'operation_name', 'string', 'nil')
|
82 |
| - check(opts, 'opts', 'table', 'nil') |
| 82 | + check(compile_opts, 'compile_opts', 'table', 'nil') |
83 | 83 |
|
84 |
| - local compiled_query = state:compile(query, opts) |
| 84 | + local compiled_query = state:compile(query, compile_opts) |
85 | 85 | return compiled_query:execute(variables, operation_name)
|
86 | 86 | end
|
87 | 87 |
|
@@ -135,14 +135,14 @@ local function gql_compile(state, query, opts)
|
135 | 135 | return gql_query
|
136 | 136 | end
|
137 | 137 |
|
138 |
| -local function start_server(gql, host, port) |
| 138 | +local function start_server(gql, host, port, compile_opts) |
139 | 139 | assert(type(gql) == 'table',
|
140 | 140 | 'use :start_server(...) instead of .start_server(...)')
|
141 | 141 |
|
142 | 142 | check(host, 'host', 'nil', 'string')
|
143 | 143 | check(port, 'port', 'nil', 'number')
|
144 | 144 |
|
145 |
| - gql.server = server.init(gql, host, port) |
| 145 | + gql.server = server.init(gql, host, port, compile_opts) |
146 | 146 | gql.server:start()
|
147 | 147 |
|
148 | 148 | return ('The GraphQL server started at http://%s:%s'):format(
|
@@ -196,26 +196,27 @@ local function create_default_accessor(cfg)
|
196 | 196 | end
|
197 | 197 | end
|
198 | 198 |
|
199 |
| -function impl.compile(query) |
| 199 | +function impl.compile(query, opts) |
200 | 200 | if default_instance == nil then
|
201 | 201 | default_instance = impl.new()
|
202 | 202 | end
|
203 |
| - return default_instance:compile(query) |
| 203 | + return default_instance:compile(query, opts) |
204 | 204 | end
|
205 | 205 |
|
206 |
| -function impl.execute(query, variables, operation_name) |
| 206 | +function impl.execute(query, variables, operation_name, compile_opts) |
207 | 207 | if default_instance == nil then
|
208 | 208 | default_instance = impl.new()
|
209 | 209 | end
|
210 |
| - return default_instance:execute(query, variables, operation_name) |
| 210 | + return default_instance:execute(query, variables, operation_name, |
| 211 | + compile_opts) |
211 | 212 | end
|
212 | 213 |
|
213 |
| -function impl.start_server() |
| 214 | +function impl.start_server(host, port, compile_opts) |
214 | 215 | if default_instance == nil then
|
215 | 216 | default_instance = impl.new()
|
216 | 217 | end
|
217 | 218 |
|
218 |
| - return default_instance:start_server() |
| 219 | + return default_instance:start_server(host, port, compile_opts) |
219 | 220 | end
|
220 | 221 |
|
221 | 222 | function impl.stop_server()
|
|
0 commit comments