grafast 0.0.1-alpha.15 → 0.0.1-alpha.16

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.
package/LICENSE.md CHANGED
@@ -1,26 +1,24 @@
1
- # Graphile Sponsors-only Software
1
+ # The MIT License (MIT)
2
2
 
3
- Copyright © 2022 Benjie Gillam. All rights reserved.
3
+ Copyright © `2023` Benjie Gillam
4
4
 
5
- This package is _not_ (yet) open source software, it may only be used by
6
- graphile sponsors. for more information, please see https://grafast.org
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the “Software”), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
7
11
 
8
- This is explicitly pre-release software, it has not yet gone through rigorous
9
- testing and probably includes security and stability issues both known and
10
- unknown. Usage of this software is entirely at your own risk.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
11
14
 
12
15
  THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
- SOFTWARE.
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
21
 
20
22
  ---
21
23
 
22
- The contents of the `node_modules` directory are produced from external
23
- libraries; their license terms will likely differ from the terms above - you
24
- should review them also.
25
-
26
24
  Licenses of bundled dependencies (if any) are detailed in dist/LICENSES.txt
package/README.md CHANGED
@@ -1,3 +1,140 @@
1
1
  # Gra*fast*
2
2
 
3
- Coming 2023! [Be notified](https://grafast.org)
3
+ [![GitHub Sponsors](https://img.shields.io/github/sponsors/benjie?color=ff69b4&label=github%20sponsors)](https://github.com/sponsors/benjie)
4
+ [![Patreon sponsor button](https://img.shields.io/badge/sponsor-via%20Patreon-orange.svg)](https://patreon.com/benjie)
5
+ [![Discord chat room](https://img.shields.io/discord/489127045289476126.svg)](http://discord.gg/graphile)
6
+ [![Follow](https://img.shields.io/badge/twitter-@GrafastHQ-blueviolet.svg)](https://twitter.com/GrafastHQ)
7
+
8
+ _**The next-generation planning and execution engine for GraphQL**_
9
+
10
+ **Documentation**: https://grafast.org/grafast/
11
+
12
+ ## About
13
+
14
+ Gra*fast* understands GraphQL and (with your help) your business logic; this
15
+ allows it to orchestrate a GraphQL request's data requirements in an extremely
16
+ efficient manner, leading to excellent performance, reduced server load, and
17
+ happier customers.
18
+
19
+ This increased efficiency is achieved by leveraging the declarative nature of
20
+ GraphQL and deeper integration with your existing Node.js or remote business
21
+ logic via "plan resolvers" attached to the fields of your schema. These plan
22
+ resolvers detail the abstract steps necessary to execute the given field, these
23
+ steps are then combined with the steps from all other fields in the request into
24
+ an operation plan. This operation plan can then be rewritten and optimized
25
+ before execution, and can often be re-used for similar queries in the future.
26
+
27
+ In addition to "plan resolvers," Gra*fast* is also backwards compatible with
28
+ traditional resolvers - in fact most existing GraphQL.js schemas should already
29
+ be executable via Gra*fast* (and doing so should result in a small speed
30
+ improvement). Replace your resolvers with Gra*fast* plan resolvers to see the
31
+ real efficiency gains!
32
+
33
+ Gra*fast* schemas can be built using the same techniques other GraphQL.js
34
+ schemas can be built - Gra*fast* schemas _are_ GraphQL.js schemas - for example
35
+ schema-first, code-first or auto-generated. If you maintain a library that
36
+ builds GraphQL schemas, get in touch - we'd love to help you integrate Gra*fast*
37
+ with it!
38
+
39
+ <!-- SPONSORS_BEGIN -->
40
+
41
+ ## Crowd-funded open-source software
42
+
43
+ To help us develop this software sustainably under the MIT license, we ask all
44
+ individuals and businesses that use it to help support its ongoing maintenance
45
+ and development via sponsorship.
46
+
47
+ ### [Click here to find out more about sponsors and sponsorship.](https://www.graphile.org/sponsor/)
48
+
49
+ And please give some love to our featured sponsors 🤩:
50
+
51
+ <table><tr>
52
+ <td align="center"><a href="https://www.the-guild.dev/"><img src="https://graphile.org/images/sponsors/theguild.png" width="90" height="90" alt="The Guild" /><br />The Guild</a> *</td>
53
+ <td align="center"><a href="https://dovetailapp.com/"><img src="https://graphile.org/images/sponsors/dovetail.png" width="90" height="90" alt="Dovetail" /><br />Dovetail</a> *</td>
54
+ <td align="center"><a href="https://qwick.com/"><img src="https://graphile.org/images/sponsors/qwick.png" width="90" height="90" alt="Qwick" /><br />Qwick</a> *</td>
55
+ <td align="center"><a href="https://www.netflix.com/"><img src="https://graphile.org/images/sponsors/Netflix.png" width="90" height="90" alt="Netflix" /><br />Netflix</a> *</td>
56
+ </tr><tr>
57
+ <td align="center"><a href=""><img src="https://graphile.org/images/sponsors/chadf.png" width="90" height="90" alt="Chad Furman" /><br />Chad Furman</a> *</td>
58
+ <td align="center"><a href="https://stellate.co/"><img src="https://graphile.org/images/sponsors/Stellate.png" width="90" height="90" alt="Stellate" /><br />Stellate</a> *</td>
59
+ <td align="center"><a href="https://www.accenture.com/"><img src="https://graphile.org/images/sponsors/accenture.svg" width="90" height="90" alt="Accenture" /><br />Accenture</a> *</td>
60
+ </tr></table>
61
+
62
+ <em>\* Sponsors the entire Graphile suite</em>
63
+
64
+ <!-- SPONSORS_END -->
65
+
66
+ ## Overview
67
+
68
+ Gra*fast* is an alternative GraphQL execution engine for JavaScript; you can use
69
+ it as a drop-in replacement for the "execute" method of GraphQL.js. Any GraphQL
70
+ server that allows replacement of the `execute` method (which includes any
71
+ server that fully supports [envelop][]) can support Gra*fast*.
72
+
73
+ When Gra*fast* sees a GraphQL request for the first time it will "plan" the
74
+ request: figuring out the data requirements, the steps that need to be taken,
75
+ and how to write the results to the response. This "first draft" plan will be
76
+ optimised and rewritten to give the best achievable performance (for example
77
+ removing redundant or duplicate processing steps, rewriting and merging
78
+ processing steps, etc). Finally, the plan will be executed, and the response
79
+ returned to the client. Future requests that are compatible with this plan can
80
+ be executed immediately without a need to re-plan.
81
+
82
+ ## Requirements
83
+
84
+ Gra*fast* should work with any GraphQL.js schema that matches the following
85
+ requirements:
86
+
87
+ - GraphQL.js v16+
88
+ - you must not override the default GraphQL field resolver (TODO: support this)
89
+ - for every request:
90
+ - `context` must be an object (anything suitable to be used as the key to a
91
+ `WeakMap`); if you do not need a context then `{}` is perfectly acceptable
92
+ - `rootValue` must be an object or `null`/`undefined`
93
+ - resolver limitations:
94
+ - only explicit field resolvers (baked into the GraphQL schema) are supported,
95
+ i.e. resolvers passed via `rootValue` are not (currently) supported
96
+ - our support for traditional GraphQL resolvers does not have full parity with
97
+ the fourth argument to `resolve` (aka `resolveInfo`) - in particular, the
98
+ `resolveInfo.path` property is not currently supported.
99
+
100
+ If you find a GraphQL schema that matches these requirements and doesn't work
101
+ with Gra*fast*, please file an issue.
102
+
103
+ ## Advice
104
+
105
+ To reap the most benefit from using Gra*fast*, you want as little to change
106
+ between executions as possible. In particular, this means you should:
107
+
108
+ - **CRITICAL**: Cache (e.g. with a LRU cache) the parsed GraphQL document, so
109
+ the same AST can be reused over and over for the same document
110
+ - `grafserv` handles this for you
111
+ - Envelop users can use `@envelop/parser-cache` for this
112
+ - Don't use `rootValue` (Do you really need it? Use `context` instead.)
113
+ - Where possible, memoize the variables object (e.g. using a cache over
114
+ `canonicalJSONStringify(variables)`) so the same variables results in the same
115
+ object in memory
116
+ - Cache (e.g. with a LRU cache) the GraphQL `context` object, so the same
117
+ context can be reused over and over for the same user
118
+ - This is less important - feel free to break it if you need to, for example
119
+ if you're still using DataLoaders during migration
120
+
121
+ ## Usage
122
+
123
+ Where you would use `graphql` from the `graphql` module, use `grafast` instead:
124
+
125
+ ```diff
126
+ -import { graphql } from "graphql";
127
+ +import { grafast as graphql } from "grafast";
128
+ ```
129
+
130
+ Where you would use `execute` from the `graphql` module, use `grafast`'s
131
+ `execute` instead:
132
+
133
+ ```diff
134
+ -import { execute } from "graphql";
135
+ +import { execute } from "grafast";
136
+ ```
137
+
138
+ ## Full documentation
139
+
140
+ https://grafast.org/grafast/
package/dist/envelop.js CHANGED
@@ -1,54 +1,5 @@
1
- const { Buffer } = require('node:buffer');
2
- const { scryptSync, createDecipheriv } = require('node:crypto');
3
- const pkgName = "grafast";
4
- const pkgVersion = "0.0.1-alpha.15";
5
-
6
- const RESET = '\x1b[0m';
7
- const BOLD_BLACK_ON_RED = '\x1b[40;31;1;7m';
8
- const RED = '\x1b[31m';
9
- const BOLD = '\x1b[1m';
10
- const BOLD_BLUE = '\x1b[34;1m';
11
- const BOLD_BLUE_UNDERLINED = '\x1b[34;1;4m';
12
-
13
- const iSponsorGraphile = `${RESET}${BOLD_BLUE}I_SPONSOR_GRAPHILE${RESET}${RED}`;
14
- const website = `${RESET}${BOLD_BLUE_UNDERLINED}https://grafast.org${RESET}`;
15
- const errorPrefix = `${BOLD_BLACK_ON_RED}[ ERROR ]${RESET} ${RED}`;
16
- const errorSuffix = `${RESET}
17
- ${BOLD_BLACK_ON_RED}[ CONTEXT ]${RESET} ${RED}You are attempting to run pre-release software that is only available to Graphile sponsors.${RESET}
18
-
19
- Please refer to the ${website} documentation for the right code to use with this version '${BOLD}${pkgName}@${pkgVersion}${RESET}'.${RESET}
20
- `;
21
-
22
- const password = process.env.I_SPONSOR_GRAPHILE;
23
- if (typeof password !== 'string') {
24
- console.error(
25
- `${errorPrefix}You must set the ${iSponsorGraphile} environmental variable to the shared secret to use this pre-release software.${errorSuffix}`,
26
- );
27
- process.exit(42);
28
- }
29
-
30
- const algorithm = "aes-192-cbc";
31
- const salt = "We wouldn't be able to do so much OSS without sponsorship. 21776549661030886";
32
- const key = scryptSync(password, salt, 24);
33
- const ivBuffer = Buffer.from("fEBkkCJeJGhakF0twHhgpw==", "base64");
34
- const iv = new Uint8Array(ivBuffer.buffer, ivBuffer.byteOffset, ivBuffer.length);
35
- const decipher = createDecipheriv(algorithm, key, iv);
36
- const encrypted = "SVZfreXeCKfixoCo2KglZqBVDEmE+d593oMh1BEoYVR+c3lbcYTjkjdS8zKowzNB59In9rNZKHOo7mBJXRq+aolaaxudzKRUARRVMPlRi6/o3SFYDaGm0tXZ8RUEuzYMqbpOZEVjbQtzbHTlQGy3Ujc4tZuK41S+POR9DjRuXKgkVosWrwf72JhoG+SGy+To7TS7DG2ZoDlrt4XileUgPEQ9pHZHX0Q90WJ7HFxcIDg0LFiAIAVtFn5ajEi9/PmEAZSqJ+7125CUqYstZm/oMSR+fdS9bcIfinump4u0WQRJmEVKqm7MOOpR4NMK15El01e/Jhr0uvWS/S/LRPjiLdAAub4wka1NYCk3cunmWHOoAhTDVuZGH3sQpZSy3Bv15hN4jG4McEbvRToPUGkZduf/fgNIy3rnDaKRF6Wat5S77LDtgFfVAk7DewACpDScLODZxjLdNWHmlx3GlCiPDaFKN6pMCshTWJYiT0aZYiLtR5zRDgTlxsvruzXdGq2Qq9bttSRLcgFL4bRMWy5NlA7EyO2QxuWYDZfcse+9H1oc0TCntEe7UsrTaK73/hfjZpFEkob5HQJTO7yvAMJxncI8QCP9VNcSY+OokfMhpSAok8sgcMVz9Oif6EcDAwmQi190U68iEvRNg7fF7Yrpk9uNgTjreS6ydzo++jRFFF8ZZp698fyJ1azF65sK0hn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vE/eVboW14PBzgp8IiY2ISppFpckZdw9ux43c6ybvxfN75B5XIqmwc4BLz2ORFNA8="
37
- let decrypted;
38
- try {
39
- decrypted = decipher.update(encrypted, 'base64', 'utf8') + decipher.final('utf8');
40
- } catch (e) {
41
- console.error(
42
- `${errorPrefix}The value for the ${iSponsorGraphile} environmental variable (value: '${password.slice(
43
- 0,
44
- 2,
45
- )}...${password.slice(-2)}') is incorrect.${errorSuffix}`,
46
- );
47
- process.exit(42);
48
- }
49
-
50
1
  // Convince Node to allow ESM named imports
51
2
 
52
3
 
53
- // Load our decrypted module
54
- eval(decrypted);
4
+ // Bundled module
5
+ "use strict";!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.grafast=r():e.grafast=r()}(this,(()=>(this.webpackChunkgrafast=this.webpackChunkgrafast||[]).push([[764],{3837:(e,r,s)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.useMoreDetailedErrors=r.useGrafast=void 0;const t=s(6587),n=s(6522),a=s(680);function o(e,r){if(!1===e||Array.isArray(e)&&0===e.length)return;const s=Array.isArray(r)?r.join(","):r;if(!s)return;const t=s.split(",");return!0===e||void 0===e?t:e.filter((e=>t.includes(e)))}r.useGrafast=(e={})=>{const{explainAllowed:r=!0}=e;return{async onExecute(e){const s=e.args.contextValue?.req?.headers["x-graphql-explain"],n=o(r,s);e.setExecuteFn((e=>(0,t.execute)(e,{grafast:{explain:n}})))},async onSubscribe(e){const s=e.args.contextValue,t=(s?.req?.headers||s?.request?.headers||s?.connectionParams)?.["x-graphql-explain"],n=o(r,t);e.setSubscribeFn((async e=>(0,a.subscribe)(e,{grafast:{explain:n}})))}}};r.useMoreDetailedErrors=()=>({onExecute:()=>({onExecuteDone({result:e}){"errors"in e&&e.errors&&(e.errors=e.errors.map((e=>{const r=e.toJSON();return Object.assign(r,{message:(0,n.stripAnsi)(r.message),extensions:{stack:(0,n.stripAnsi)(e.stack??"").split("\n")}})})))}})})}},e=>{var r;return r=3837,e(e.s=r)}])));