bluejay 0.1.0.alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/Cargo.lock +423 -0
  3. data/Cargo.toml +2 -0
  4. data/LICENSE +21 -0
  5. data/README.md +33 -0
  6. data/ext/Cargo.toml +17 -0
  7. data/ext/extconf.rb +6 -0
  8. data/ext/src/execution/coerce_result.rs +54 -0
  9. data/ext/src/execution/engine.rs +466 -0
  10. data/ext/src/execution/execution_error.rs +28 -0
  11. data/ext/src/execution/field_error.rs +8 -0
  12. data/ext/src/execution/key_store.rs +23 -0
  13. data/ext/src/execution.rs +10 -0
  14. data/ext/src/helpers/public_name.rs +21 -0
  15. data/ext/src/helpers/typed_frozen_r_array.rs +56 -0
  16. data/ext/src/helpers/wrapped_definition.rs +79 -0
  17. data/ext/src/helpers/wrapped_struct.rs +97 -0
  18. data/ext/src/helpers.rs +8 -0
  19. data/ext/src/lib.rs +10 -0
  20. data/ext/src/ruby_api/arguments_definition.rs +8 -0
  21. data/ext/src/ruby_api/coerce_input.rs +6 -0
  22. data/ext/src/ruby_api/coercion_error.rs +61 -0
  23. data/ext/src/ruby_api/custom_scalar_type_definition.rs +62 -0
  24. data/ext/src/ruby_api/enum_type_definition.rs +107 -0
  25. data/ext/src/ruby_api/enum_value_definition.rs +58 -0
  26. data/ext/src/ruby_api/enum_value_definitions.rs +8 -0
  27. data/ext/src/ruby_api/execution_error.rs +48 -0
  28. data/ext/src/ruby_api/execution_result.rs +40 -0
  29. data/ext/src/ruby_api/field_definition.rs +112 -0
  30. data/ext/src/ruby_api/fields_definition.rs +8 -0
  31. data/ext/src/ruby_api/input_fields_definition.rs +8 -0
  32. data/ext/src/ruby_api/input_object_type_definition.rs +138 -0
  33. data/ext/src/ruby_api/input_type_reference.rs +358 -0
  34. data/ext/src/ruby_api/input_value_definition.rs +98 -0
  35. data/ext/src/ruby_api/interface_implementation.rs +42 -0
  36. data/ext/src/ruby_api/interface_implementations.rs +8 -0
  37. data/ext/src/ruby_api/interface_type_definition.rs +82 -0
  38. data/ext/src/ruby_api/json_value.rs +111 -0
  39. data/ext/src/ruby_api/object_type_definition.rs +100 -0
  40. data/ext/src/ruby_api/output_type_reference.rs +238 -0
  41. data/ext/src/ruby_api/r_result.rs +84 -0
  42. data/ext/src/ruby_api/scalar.rs +45 -0
  43. data/ext/src/ruby_api/schema_definition.rs +270 -0
  44. data/ext/src/ruby_api/union_member_type.rs +41 -0
  45. data/ext/src/ruby_api/union_member_types.rs +8 -0
  46. data/ext/src/ruby_api/union_type_definition.rs +89 -0
  47. data/ext/src/ruby_api/validation_error.rs +63 -0
  48. data/ext/src/ruby_api.rs +75 -0
  49. data/lib/bluejay/base_input_type_reference.rb +13 -0
  50. data/lib/bluejay/base_output_type_reference.rb +15 -0
  51. data/lib/bluejay/custom_scalar_type.rb +40 -0
  52. data/lib/bluejay/enum_type.rb +44 -0
  53. data/lib/bluejay/ext.bundle +0 -0
  54. data/lib/bluejay/finalize.rb +27 -0
  55. data/lib/bluejay/input_type.rb +64 -0
  56. data/lib/bluejay/input_type_reference_shorthands.rb +28 -0
  57. data/lib/bluejay/interface_type.rb +60 -0
  58. data/lib/bluejay/json_value.rb +16 -0
  59. data/lib/bluejay/name_from_class.rb +18 -0
  60. data/lib/bluejay/object_type.rb +68 -0
  61. data/lib/bluejay/output_type_reference_shorthands.rb +28 -0
  62. data/lib/bluejay/schema.rb +63 -0
  63. data/lib/bluejay/union_type.rb +43 -0
  64. data/lib/bluejay/version.rb +5 -0
  65. data/lib/bluejay.rb +28 -0
  66. data/lib/rbi_ext/model.rb +64 -0
  67. data/lib/tapioca/dsl/compilers/input_type.rb +34 -0
  68. data/lib/tapioca/dsl/compilers/interface_type.rb +29 -0
  69. data/lib/tapioca/dsl/compilers/object_type.rb +43 -0
  70. data/lib/tapioca/dsl/compilers/schema.rb +42 -0
  71. metadata +131 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 44d1325cd99c09116119d31ebceeb5d7e850c535fee0260c72056dfc8cd05f8c
4
+ data.tar.gz: bda7ecce529d6fe3b6f52e92e4783a60d2780dfaf6a082618ed40c7a7c0e3da9
5
+ SHA512:
6
+ metadata.gz: 1166725cafea346f279e20e588aec26f565946cf1eed78a4be4465e229c2524a123e36a577d2543f4a824ccbc8a280f37a1f9a8e738a4c04c123c2d34e6646b5
7
+ data.tar.gz: bc704bc76d57ec3f8f2c85e210d4df61bd24d94107532a1c6bbbb01c77f958b5f9d8a26e4f0d5998a7aa348faa7b7ae20456e8e4a9feab4ffa4350974c5f22c8
data/Cargo.lock ADDED
@@ -0,0 +1,423 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 3
4
+
5
+ [[package]]
6
+ name = "aho-corasick"
7
+ version = "0.7.20"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
10
+ dependencies = [
11
+ "memchr",
12
+ ]
13
+
14
+ [[package]]
15
+ name = "beef"
16
+ version = "0.5.2"
17
+ source = "registry+https://github.com/rust-lang/crates.io-index"
18
+ checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1"
19
+
20
+ [[package]]
21
+ name = "bindgen"
22
+ version = "0.60.1"
23
+ source = "registry+https://github.com/rust-lang/crates.io-index"
24
+ checksum = "062dddbc1ba4aca46de6338e2bf87771414c335f7b2f2036e8f3e9befebf88e6"
25
+ dependencies = [
26
+ "bitflags",
27
+ "cexpr",
28
+ "clang-sys",
29
+ "lazy_static",
30
+ "lazycell",
31
+ "peeking_take_while",
32
+ "proc-macro2",
33
+ "quote",
34
+ "regex",
35
+ "rustc-hash",
36
+ "shlex",
37
+ ]
38
+
39
+ [[package]]
40
+ name = "bitflags"
41
+ version = "1.3.2"
42
+ source = "registry+https://github.com/rust-lang/crates.io-index"
43
+ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
44
+
45
+ [[package]]
46
+ name = "bluejay-core"
47
+ version = "0.1.0-alpha.0"
48
+ source = "registry+https://github.com/rust-lang/crates.io-index"
49
+ checksum = "c91de4555af4889e59f7b84aa51469523aba476c5db98ce65db4e0b502feaa07"
50
+ dependencies = [
51
+ "itertools",
52
+ "paste",
53
+ "strum",
54
+ ]
55
+
56
+ [[package]]
57
+ name = "bluejay-parser"
58
+ version = "0.1.0-alpha.0"
59
+ source = "registry+https://github.com/rust-lang/crates.io-index"
60
+ checksum = "6a412dfc891ec90dd8464ac6ea678b3561ac6660930d1183bc3d3afccffcba53"
61
+ dependencies = [
62
+ "bluejay-core",
63
+ "enum-as-inner",
64
+ "logos",
65
+ ]
66
+
67
+ [[package]]
68
+ name = "cexpr"
69
+ version = "0.6.0"
70
+ source = "registry+https://github.com/rust-lang/crates.io-index"
71
+ checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
72
+ dependencies = [
73
+ "nom",
74
+ ]
75
+
76
+ [[package]]
77
+ name = "cfg-if"
78
+ version = "1.0.0"
79
+ source = "registry+https://github.com/rust-lang/crates.io-index"
80
+ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
81
+
82
+ [[package]]
83
+ name = "clang-sys"
84
+ version = "1.4.0"
85
+ source = "registry+https://github.com/rust-lang/crates.io-index"
86
+ checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3"
87
+ dependencies = [
88
+ "glob",
89
+ "libc",
90
+ "libloading",
91
+ ]
92
+
93
+ [[package]]
94
+ name = "convert_case"
95
+ version = "0.6.0"
96
+ source = "registry+https://github.com/rust-lang/crates.io-index"
97
+ checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
98
+ dependencies = [
99
+ "unicode-segmentation",
100
+ ]
101
+
102
+ [[package]]
103
+ name = "either"
104
+ version = "1.8.0"
105
+ source = "registry+https://github.com/rust-lang/crates.io-index"
106
+ checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
107
+
108
+ [[package]]
109
+ name = "enum-as-inner"
110
+ version = "0.5.1"
111
+ source = "registry+https://github.com/rust-lang/crates.io-index"
112
+ checksum = "c9720bba047d567ffc8a3cba48bf19126600e249ab7f128e9233e6376976a116"
113
+ dependencies = [
114
+ "heck",
115
+ "proc-macro2",
116
+ "quote",
117
+ "syn",
118
+ ]
119
+
120
+ [[package]]
121
+ name = "ext"
122
+ version = "0.1.0"
123
+ dependencies = [
124
+ "bluejay-core",
125
+ "bluejay-parser",
126
+ "convert_case",
127
+ "itertools",
128
+ "magnus",
129
+ "once_cell",
130
+ "rb-sys",
131
+ ]
132
+
133
+ [[package]]
134
+ name = "fnv"
135
+ version = "1.0.7"
136
+ source = "registry+https://github.com/rust-lang/crates.io-index"
137
+ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
138
+
139
+ [[package]]
140
+ name = "glob"
141
+ version = "0.3.0"
142
+ source = "registry+https://github.com/rust-lang/crates.io-index"
143
+ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
144
+
145
+ [[package]]
146
+ name = "heck"
147
+ version = "0.4.0"
148
+ source = "registry+https://github.com/rust-lang/crates.io-index"
149
+ checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
150
+
151
+ [[package]]
152
+ name = "itertools"
153
+ version = "0.10.5"
154
+ source = "registry+https://github.com/rust-lang/crates.io-index"
155
+ checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473"
156
+ dependencies = [
157
+ "either",
158
+ ]
159
+
160
+ [[package]]
161
+ name = "lazy_static"
162
+ version = "1.4.0"
163
+ source = "registry+https://github.com/rust-lang/crates.io-index"
164
+ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
165
+
166
+ [[package]]
167
+ name = "lazycell"
168
+ version = "1.3.0"
169
+ source = "registry+https://github.com/rust-lang/crates.io-index"
170
+ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
171
+
172
+ [[package]]
173
+ name = "libc"
174
+ version = "0.2.137"
175
+ source = "registry+https://github.com/rust-lang/crates.io-index"
176
+ checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
177
+
178
+ [[package]]
179
+ name = "libloading"
180
+ version = "0.7.4"
181
+ source = "registry+https://github.com/rust-lang/crates.io-index"
182
+ checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
183
+ dependencies = [
184
+ "cfg-if",
185
+ "winapi",
186
+ ]
187
+
188
+ [[package]]
189
+ name = "logos"
190
+ version = "0.12.1"
191
+ source = "registry+https://github.com/rust-lang/crates.io-index"
192
+ checksum = "bf8b031682c67a8e3d5446840f9573eb7fe26efe7ec8d195c9ac4c0647c502f1"
193
+ dependencies = [
194
+ "logos-derive",
195
+ ]
196
+
197
+ [[package]]
198
+ name = "logos-derive"
199
+ version = "0.12.1"
200
+ source = "registry+https://github.com/rust-lang/crates.io-index"
201
+ checksum = "a1d849148dbaf9661a6151d1ca82b13bb4c4c128146a88d05253b38d4e2f496c"
202
+ dependencies = [
203
+ "beef",
204
+ "fnv",
205
+ "proc-macro2",
206
+ "quote",
207
+ "regex-syntax",
208
+ "syn",
209
+ ]
210
+
211
+ [[package]]
212
+ name = "magnus"
213
+ version = "0.4.4"
214
+ source = "registry+https://github.com/rust-lang/crates.io-index"
215
+ checksum = "fc87660cd7daa49fddbfd524c836de54d5c927d520cd163f43700c5087c57d6c"
216
+ dependencies = [
217
+ "magnus-macros",
218
+ "rb-sys",
219
+ "rb-sys-env",
220
+ ]
221
+
222
+ [[package]]
223
+ name = "magnus-macros"
224
+ version = "0.3.0"
225
+ source = "registry+https://github.com/rust-lang/crates.io-index"
226
+ checksum = "206cb23bfeea05180c97522ef6a3e52a4eb17b0ed2f30ee3ca9c4f994d2378ae"
227
+ dependencies = [
228
+ "proc-macro2",
229
+ "quote",
230
+ "syn",
231
+ ]
232
+
233
+ [[package]]
234
+ name = "memchr"
235
+ version = "2.5.0"
236
+ source = "registry+https://github.com/rust-lang/crates.io-index"
237
+ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
238
+
239
+ [[package]]
240
+ name = "minimal-lexical"
241
+ version = "0.2.1"
242
+ source = "registry+https://github.com/rust-lang/crates.io-index"
243
+ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
244
+
245
+ [[package]]
246
+ name = "nom"
247
+ version = "7.1.1"
248
+ source = "registry+https://github.com/rust-lang/crates.io-index"
249
+ checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36"
250
+ dependencies = [
251
+ "memchr",
252
+ "minimal-lexical",
253
+ ]
254
+
255
+ [[package]]
256
+ name = "once_cell"
257
+ version = "1.17.0"
258
+ source = "registry+https://github.com/rust-lang/crates.io-index"
259
+ checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
260
+
261
+ [[package]]
262
+ name = "paste"
263
+ version = "1.0.11"
264
+ source = "registry+https://github.com/rust-lang/crates.io-index"
265
+ checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba"
266
+
267
+ [[package]]
268
+ name = "peeking_take_while"
269
+ version = "0.1.2"
270
+ source = "registry+https://github.com/rust-lang/crates.io-index"
271
+ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
272
+
273
+ [[package]]
274
+ name = "proc-macro2"
275
+ version = "1.0.47"
276
+ source = "registry+https://github.com/rust-lang/crates.io-index"
277
+ checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
278
+ dependencies = [
279
+ "unicode-ident",
280
+ ]
281
+
282
+ [[package]]
283
+ name = "quote"
284
+ version = "1.0.21"
285
+ source = "registry+https://github.com/rust-lang/crates.io-index"
286
+ checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
287
+ dependencies = [
288
+ "proc-macro2",
289
+ ]
290
+
291
+ [[package]]
292
+ name = "rb-sys"
293
+ version = "0.9.53"
294
+ source = "registry+https://github.com/rust-lang/crates.io-index"
295
+ checksum = "aa291f69bcc44f8e96597a3f39e9933fde6977b825415cfaa670ac49b8ab7c99"
296
+ dependencies = [
297
+ "rb-sys-build",
298
+ ]
299
+
300
+ [[package]]
301
+ name = "rb-sys-build"
302
+ version = "0.9.53"
303
+ source = "registry+https://github.com/rust-lang/crates.io-index"
304
+ checksum = "d998fd6ef588471d6d7cca24c4da88eda5e6757b6885c55760e856ecdb254c3d"
305
+ dependencies = [
306
+ "bindgen",
307
+ "regex",
308
+ "shell-words",
309
+ ]
310
+
311
+ [[package]]
312
+ name = "rb-sys-env"
313
+ version = "0.1.1"
314
+ source = "registry+https://github.com/rust-lang/crates.io-index"
315
+ checksum = "74c38752410925faeb82c400c06ba2fd9ee6aa8f719dd33994c9e53f5242d25f"
316
+
317
+ [[package]]
318
+ name = "regex"
319
+ version = "1.7.0"
320
+ source = "registry+https://github.com/rust-lang/crates.io-index"
321
+ checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a"
322
+ dependencies = [
323
+ "aho-corasick",
324
+ "memchr",
325
+ "regex-syntax",
326
+ ]
327
+
328
+ [[package]]
329
+ name = "regex-syntax"
330
+ version = "0.6.28"
331
+ source = "registry+https://github.com/rust-lang/crates.io-index"
332
+ checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
333
+
334
+ [[package]]
335
+ name = "rustc-hash"
336
+ version = "1.1.0"
337
+ source = "registry+https://github.com/rust-lang/crates.io-index"
338
+ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
339
+
340
+ [[package]]
341
+ name = "rustversion"
342
+ version = "1.0.9"
343
+ source = "registry+https://github.com/rust-lang/crates.io-index"
344
+ checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8"
345
+
346
+ [[package]]
347
+ name = "shell-words"
348
+ version = "1.1.0"
349
+ source = "registry+https://github.com/rust-lang/crates.io-index"
350
+ checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
351
+
352
+ [[package]]
353
+ name = "shlex"
354
+ version = "1.1.0"
355
+ source = "registry+https://github.com/rust-lang/crates.io-index"
356
+ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
357
+
358
+ [[package]]
359
+ name = "strum"
360
+ version = "0.24.1"
361
+ source = "registry+https://github.com/rust-lang/crates.io-index"
362
+ checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f"
363
+ dependencies = [
364
+ "strum_macros",
365
+ ]
366
+
367
+ [[package]]
368
+ name = "strum_macros"
369
+ version = "0.24.3"
370
+ source = "registry+https://github.com/rust-lang/crates.io-index"
371
+ checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59"
372
+ dependencies = [
373
+ "heck",
374
+ "proc-macro2",
375
+ "quote",
376
+ "rustversion",
377
+ "syn",
378
+ ]
379
+
380
+ [[package]]
381
+ name = "syn"
382
+ version = "1.0.103"
383
+ source = "registry+https://github.com/rust-lang/crates.io-index"
384
+ checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d"
385
+ dependencies = [
386
+ "proc-macro2",
387
+ "quote",
388
+ "unicode-ident",
389
+ ]
390
+
391
+ [[package]]
392
+ name = "unicode-ident"
393
+ version = "1.0.5"
394
+ source = "registry+https://github.com/rust-lang/crates.io-index"
395
+ checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
396
+
397
+ [[package]]
398
+ name = "unicode-segmentation"
399
+ version = "1.10.0"
400
+ source = "registry+https://github.com/rust-lang/crates.io-index"
401
+ checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a"
402
+
403
+ [[package]]
404
+ name = "winapi"
405
+ version = "0.3.9"
406
+ source = "registry+https://github.com/rust-lang/crates.io-index"
407
+ checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
408
+ dependencies = [
409
+ "winapi-i686-pc-windows-gnu",
410
+ "winapi-x86_64-pc-windows-gnu",
411
+ ]
412
+
413
+ [[package]]
414
+ name = "winapi-i686-pc-windows-gnu"
415
+ version = "0.4.0"
416
+ source = "registry+https://github.com/rust-lang/crates.io-index"
417
+ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
418
+
419
+ [[package]]
420
+ name = "winapi-x86_64-pc-windows-gnu"
421
+ version = "0.4.0"
422
+ source = "registry+https://github.com/rust-lang/crates.io-index"
423
+ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
data/Cargo.toml ADDED
@@ -0,0 +1,2 @@
1
+ [workspace]
2
+ members = ["ext"]
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Adam Petro
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # `bluejay-rb`
2
+
3
+ > **Warning**
4
+ > This project is still very early in its development and should be considered highly unstable and experimental. It is not ready for production use.
5
+
6
+ > **Note**
7
+ > In an effort to get a working proof-of-concept, documentation and test coverage has been sacrificied. This will be corrected prior to a stable release.
8
+
9
+ `bluejay-rb` is a GraphQL engine for Ruby written primarily in Rust through the use of [`magnus`](https://github.com/matsadler/magnus).
10
+
11
+ ## Goal
12
+
13
+ `bluejay-rb`'s goal is to provide a lightning fast GraphQL engine with first-class integration with [Sorbet](https://sorbet.org/).
14
+
15
+ ## Installation
16
+
17
+ Install the gem and add to the application's Gemfile by executing:
18
+
19
+ $ bundle add bluejay
20
+
21
+ If bundler is not being used to manage dependencies, install the gem by executing:
22
+
23
+ $ gem install bluejay
24
+
25
+ ## Usage
26
+
27
+ See an example in the [`/example`](/example) directory. Note the usage of [Tapioca](https://github.com/Shopify/tapioca) RBI generation for the DSL at [`/example/sorbet/rbi/dsl/graph`](/example/sorbet/rbi/dsl/graph)
28
+
29
+ ## Development
30
+
31
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
32
+
33
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
data/ext/Cargo.toml ADDED
@@ -0,0 +1,17 @@
1
+ [package]
2
+ name = "ext"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+ publish = false
6
+
7
+ [lib]
8
+ crate-type = ["cdylib"]
9
+
10
+ [dependencies]
11
+ magnus = { version = "0.4", features = ["rb-sys-interop"] }
12
+ rb-sys = "0.9"
13
+ once_cell = "1.17"
14
+ convert_case = "0.6.0"
15
+ itertools = "0.10.5"
16
+ bluejay-parser = { version = "0.1.0-alpha.0" }
17
+ bluejay-core = { version = "0.1.0-alpha.0" }
data/ext/extconf.rb ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+ require "rb_sys/mkmf"
5
+
6
+ create_rust_makefile("ext")
@@ -0,0 +1,54 @@
1
+ use crate::execution::FieldError;
2
+ use magnus::{Value, Float, Integer};
3
+ use bluejay_core::BuiltinScalarDefinition;
4
+
5
+ pub trait CoerceResult {
6
+ fn coerce_result(&self, value: Value) -> Result<Value, FieldError>;
7
+ }
8
+
9
+ impl CoerceResult for BuiltinScalarDefinition {
10
+ fn coerce_result(&self, value: Value) -> Result<Value, FieldError> {
11
+ match self {
12
+ Self::Boolean => {
13
+ if value.is_kind_of(magnus::class::true_class()) || value.is_kind_of(magnus::class::false_class()) {
14
+ Ok(value)
15
+ } else {
16
+ Err(FieldError::CannotCoerceResultToBuiltinScalar { builtin_scalar: *self })
17
+ }
18
+ },
19
+ Self::Float => {
20
+ // TODO: handle BigDecimal and possibly Numeric
21
+ if matches!(Float::from_value(value), Some(f) if f.to_f64().is_finite()) {
22
+ Ok(value)
23
+ } else if value.is_kind_of(magnus::class::integer()) {
24
+ Ok(value.funcall("to_f", ()).unwrap())
25
+ } else {
26
+ Err(FieldError::CannotCoerceResultToBuiltinScalar { builtin_scalar: *self })
27
+ }
28
+ },
29
+ Self::ID => {
30
+ if value.is_kind_of(magnus::class::string()) {
31
+ Ok(value)
32
+ } else if value.is_kind_of(magnus::class::integer()) {
33
+ Ok(value.funcall("to_s", ()).unwrap())
34
+ } else {
35
+ Err(FieldError::CannotCoerceResultToBuiltinScalar { builtin_scalar: *self })
36
+ }
37
+ },
38
+ Self::Int => {
39
+ if matches!(Integer::from_value(value), Some(i) if i.to_i32().is_ok()) {
40
+ Ok(value)
41
+ } else {
42
+ Err(FieldError::CannotCoerceResultToBuiltinScalar { builtin_scalar: *self })
43
+ }
44
+ },
45
+ Self::String => {
46
+ if value.is_kind_of(magnus::class::string()) {
47
+ Ok(value)
48
+ } else {
49
+ Err(FieldError::CannotCoerceResultToBuiltinScalar { builtin_scalar: *self })
50
+ }
51
+ },
52
+ }
53
+ }
54
+ }