agoo 2.15.0 → 2.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/ext/agoo/gqleval.c +14 -2
- data/ext/agoo/request.c +19 -0
- data/ext/agoo/rgraphql.c +24 -2
- data/ext/agoo/rserver.c +20 -10
- data/lib/agoo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74cca7bbc7156c967212d01e349f2d9134af318c8abd59687167fa5580773e54
|
4
|
+
data.tar.gz: cf765b3109277f2caa4fbb2c25d5352990fd03a394a78de82cf81ed4b235b6f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50ef0edcf1dcec15be40de1594ddd9dbbec5749fd9099f140ffd0ce986a50728d3ff442e63f4a2756f0bdcd082618cf37a183b31676c432cddb07f4ec916d48f
|
7
|
+
data.tar.gz: 485447bbd3013e516472a8f6531316eb5d1b4144b3197359425cc838807878756c990145c68ecaa5322a157ce93601a671449291fbece8cae05f0fe35d9c1f56
|
data/CHANGELOG.md
CHANGED
@@ -2,12 +2,30 @@
|
|
2
2
|
|
3
3
|
All changes to the Agoo gem are documented here. Releases follow semantic versioning.
|
4
4
|
|
5
|
+
## [2.15.1] - 2022-06-18
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
- Introspection can now be disabled with the `hide_schema` option to the Agoo server.
|
10
|
+
|
11
|
+
- If an exception raised from a GraphQL callback responds to `code`
|
12
|
+
that code will be used as the HTTP status.
|
13
|
+
|
14
|
+
- Added missing ability to set or add elements of a request argument
|
15
|
+
on GraphQL callback methods.
|
16
|
+
|
5
17
|
## [2.15.0] - 2022-05-20
|
6
18
|
|
7
19
|
### Added
|
8
20
|
|
9
21
|
- Support added for PATCH.
|
10
22
|
|
23
|
+
- A `:hide_schema` option has been added to show the graphql/schema as
|
24
|
+
not found unless added by with the handle method of the server.
|
25
|
+
|
26
|
+
- Raising an exception that responds to `code` in a graphql resolve
|
27
|
+
function will return that code as the HTTP status code.
|
28
|
+
|
11
29
|
## [2.14.3] - 2022-05-05
|
12
30
|
|
13
31
|
### Fixed
|
data/ext/agoo/gqleval.c
CHANGED
@@ -478,8 +478,14 @@ gql_eval_get_hook(agooReq req) {
|
|
478
478
|
result = gql_doc_eval_func(&err, doc);
|
479
479
|
}
|
480
480
|
if (NULL == result) {
|
481
|
+
int code = 500;
|
482
|
+
|
483
|
+
if (err.code < 0) {
|
484
|
+
code = -err.code;
|
485
|
+
}
|
486
|
+
err.code = AGOO_ERR_EVAL;
|
481
487
|
gql_doc_destroy(doc);
|
482
|
-
err_resp(req->res, &err,
|
488
|
+
err_resp(req->res, &err, code);
|
483
489
|
return;
|
484
490
|
}
|
485
491
|
if (GQL_SUBSCRIPTION == doc->op->kind) {
|
@@ -648,7 +654,13 @@ gql_eval_post_hook(agooReq req) {
|
|
648
654
|
indent = (int)strtol(s, NULL, 10);
|
649
655
|
}
|
650
656
|
if (NULL == (result = eval_post(&err, req)) && AGOO_ERR_OK != err.code) {
|
651
|
-
|
657
|
+
int code = 400;
|
658
|
+
|
659
|
+
if (err.code < 0) {
|
660
|
+
code = -err.code;
|
661
|
+
}
|
662
|
+
err.code = AGOO_ERR_EVAL;
|
663
|
+
err_resp(req->res, &err, code);
|
652
664
|
} else if (NULL == result) {
|
653
665
|
value_resp(req, result, 200, indent);
|
654
666
|
} else {
|
data/ext/agoo/request.c
CHANGED
@@ -684,6 +684,24 @@ call(VALUE self) {
|
|
684
684
|
return io;
|
685
685
|
}
|
686
686
|
|
687
|
+
/* Document-method: set
|
688
|
+
*
|
689
|
+
* call-seq: set()
|
690
|
+
*
|
691
|
+
* Sets an key value pair to the environment of the request.
|
692
|
+
*/
|
693
|
+
static VALUE
|
694
|
+
set(VALUE self, VALUE key, VALUE val) {
|
695
|
+
agooReq r = DATA_PTR(self);
|
696
|
+
|
697
|
+
if (NULL == r) {
|
698
|
+
rb_raise(rb_eArgError, "Request is no longer valid.");
|
699
|
+
}
|
700
|
+
rb_hash_aset((VALUE)r->env, key, val);
|
701
|
+
|
702
|
+
return Qnil;
|
703
|
+
}
|
704
|
+
|
687
705
|
VALUE
|
688
706
|
request_wrap(agooReq req) {
|
689
707
|
// freed from the C side of things
|
@@ -723,6 +741,7 @@ request_init(VALUE mod) {
|
|
723
741
|
rb_define_method(req_class, "body", body, 0);
|
724
742
|
rb_define_method(req_class, "rack_logger", rack_logger, 0);
|
725
743
|
rb_define_method(req_class, "call", call, 0);
|
744
|
+
rb_define_method(req_class, "set", set, 2);
|
726
745
|
|
727
746
|
new_id = rb_intern("new");
|
728
747
|
|
data/ext/agoo/rgraphql.c
CHANGED
@@ -58,8 +58,24 @@ make_ruby_use(agooErr err,
|
|
58
58
|
volatile VALUE v;
|
59
59
|
ID m = rb_intern(method);
|
60
60
|
|
61
|
-
if (!rb_respond_to(root, m)
|
62
|
-
|
61
|
+
if (!rb_respond_to(root, m)) {
|
62
|
+
return AGOO_ERR_OK;
|
63
|
+
}
|
64
|
+
switch (rb_obj_method_arity(root, m)) {
|
65
|
+
case 0:
|
66
|
+
v = rb_funcall(root, m, 0);
|
67
|
+
break;
|
68
|
+
case 1:
|
69
|
+
v = rb_funcall(root, m, 1, Qnil);
|
70
|
+
break;
|
71
|
+
case 2:
|
72
|
+
v = rb_funcall(root, m, 2, Qnil, Qnil);
|
73
|
+
break;
|
74
|
+
default:
|
75
|
+
v = Qnil;
|
76
|
+
break;
|
77
|
+
}
|
78
|
+
if (Qnil == v) {
|
63
79
|
return AGOO_ERR_OK;
|
64
80
|
}
|
65
81
|
if (NULL == (type = gql_type_get(type_name))) {
|
@@ -89,7 +105,13 @@ rescue_error(VALUE x, VALUE ignore) {
|
|
89
105
|
const char *ms = rb_string_value_ptr(&msg);
|
90
106
|
|
91
107
|
agoo_err_set(eval->err, AGOO_ERR_EVAL, "%s: %s", classname, ms);
|
108
|
+
if (rb_respond_to(info, rb_intern("code"))) {
|
109
|
+
VALUE code = rb_funcall(info, rb_intern("code"), 0);
|
92
110
|
|
111
|
+
if (RUBY_T_FIXNUM == rb_type(code)) {
|
112
|
+
eval->err->code = -FIX2INT(code);
|
113
|
+
}
|
114
|
+
}
|
93
115
|
return Qfalse;
|
94
116
|
}
|
95
117
|
|
data/ext/agoo/rserver.c
CHANGED
@@ -208,12 +208,12 @@ configure(agooErr err, int port, const char *root, VALUE options) {
|
|
208
208
|
}
|
209
209
|
if (Qnil != (v = rb_hash_lookup(options, ID2SYM(rb_intern("graphql"))))) {
|
210
210
|
const char *path;
|
211
|
-
agooHook dump_hook;
|
212
211
|
agooHook get_hook;
|
213
212
|
agooHook post_hook;
|
214
213
|
agooHook options_hook;
|
215
|
-
|
214
|
+
agooHook head = NULL;
|
216
215
|
long plen;
|
216
|
+
VALUE hide_schema = Qnil;
|
217
217
|
|
218
218
|
rb_check_type(v, T_STRING);
|
219
219
|
if (AGOO_ERR_OK != gql_init(err)) {
|
@@ -221,21 +221,29 @@ configure(agooErr err, int port, const char *root, VALUE options) {
|
|
221
221
|
}
|
222
222
|
path = StringValuePtr(v);
|
223
223
|
plen = (long)RSTRING_LEN(v);
|
224
|
-
if ((int)sizeof(schema_path) - 8 < plen) {
|
225
|
-
rb_raise(rb_eArgError, "A graphql schema path is limited to %d characters.", (int)(sizeof(schema_path) - 8));
|
226
|
-
}
|
227
|
-
memcpy(schema_path, path, plen);
|
228
|
-
memcpy(schema_path + plen, "/schema", 8);
|
229
224
|
|
230
|
-
dump_hook = agoo_hook_func_create(AGOO_GET, schema_path, gql_dump_hook, &agoo_server.eval_queue);
|
231
225
|
get_hook = agoo_hook_func_create(AGOO_GET, path, gql_eval_get_hook, &agoo_server.eval_queue);
|
232
226
|
post_hook = agoo_hook_func_create(AGOO_POST, path, gql_eval_post_hook, &agoo_server.eval_queue);
|
233
227
|
options_hook = agoo_hook_func_create(AGOO_OPTIONS, path, gql_eval_options_hook, &agoo_server.eval_queue);
|
234
|
-
|
228
|
+
if (Qnil != (hide_schema = rb_hash_lookup(options, ID2SYM(rb_intern("hide_schema")))) && Qtrue == hide_schema) {
|
229
|
+
head = get_hook;
|
230
|
+
} else {
|
231
|
+
char schema_path[256];
|
232
|
+
agooHook dump_hook;
|
233
|
+
|
234
|
+
if ((int)sizeof(schema_path) - 8 < plen) {
|
235
|
+
rb_raise(rb_eArgError, "A graphql schema path is limited to %d characters.", (int)(sizeof(schema_path) - 8));
|
236
|
+
}
|
237
|
+
memcpy(schema_path, path, plen);
|
238
|
+
memcpy(schema_path + plen, "/schema", 8);
|
239
|
+
dump_hook = agoo_hook_func_create(AGOO_GET, schema_path, gql_dump_hook, &agoo_server.eval_queue);
|
240
|
+
dump_hook->next = get_hook;
|
241
|
+
head = dump_hook;
|
242
|
+
}
|
235
243
|
get_hook->next = post_hook;
|
236
244
|
post_hook->next = options_hook;
|
237
245
|
options_hook->next = agoo_server.hooks;
|
238
|
-
agoo_server.hooks =
|
246
|
+
agoo_server.hooks = head;
|
239
247
|
}
|
240
248
|
if (Qnil != (v = rb_hash_lookup(options, ID2SYM(rb_intern("quiet"))))) {
|
241
249
|
if (Qtrue == v) {
|
@@ -296,6 +304,8 @@ configure(agooErr err, int port, const char *root, VALUE options) {
|
|
296
304
|
* - *:ssl_sert* [_String_] filepath to the SSL certificate file.
|
297
305
|
*
|
298
306
|
* - *:ssl_key* [_String_] filepath to the SSL private key file.
|
307
|
+
*
|
308
|
+
* - *:hide_schema* [_true_|_false_] if true the graphql/schema path is handled.
|
299
309
|
*/
|
300
310
|
static VALUE
|
301
311
|
rserver_init(int argc, VALUE *argv, VALUE self) {
|
data/lib/agoo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.15.
|
4
|
+
version: 2.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|