├── .gitignore ├── .prettierrc ├── CODE_OF_CONDUCT.md ├── LICENSE_APACHE ├── LICENSE_MIT ├── README.md ├── index.js ├── introspection.js ├── package-lock.json ├── package.json ├── wrangler.toml └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /dist 3 | **/*.rs.bk 4 | Cargo.lock 5 | bin/ 6 | pkg/ 7 | wasm-pack.log 8 | worker/ 9 | node_modules/ 10 | .cargo-ok 11 | *.log 12 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "semi": false, 4 | "trailingComma": "all", 5 | "tabWidth": 2, 6 | "printWidth": 80 7 | } 8 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | - Using welcoming and inclusive language 18 | - Being respectful of differing viewpoints and experiences 19 | - Gracefully accepting constructive criticism 20 | - Focusing on what is best for the community 21 | - Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | - The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | - Trolling, insulting/derogatory comments, and personal or political attacks 28 | - Public or private harassment 29 | - Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | - Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at ag_dubs@cloudflare.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /LICENSE_APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | -------------------------------------------------------------------------------- /LICENSE_MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Ashley Williams 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # workers-graphql-proxy 2 | 3 | [![Deploy to Cloudflare Workers](https://deploy-to-cf-workers.signalnerve.workers.dev/button)](https://deploy-to-cf-workers.signalnerve.workers.dev/?url=https://github.com/signalnerve/workers-graphql-proxy) 4 | 5 | A Cloudflare Workers application for proxying GraphQL requests to a known origin, along with some goodies: 6 | 7 | - Simple URL-based routing to your GraphQL server 8 | - Schema caching at the edge 9 | - Schema validation for incoming queries 10 | - Query/response caching at the edge using Workers KV (this is super experimental and not recommended for production data) 11 | 12 | workers-graphql-proxy has been designed for usage with Hasura GraphQL Engine - check out my upcoming talk at HasuraCon 2020 to learn more about the project! 13 | 14 | ## Deployment 15 | 16 | _Coming soon_ 17 | 18 | ## License 19 | 20 | MIT 21 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import { parse, validate } from 'graphql' 2 | import { rawRequest } from 'graphql-request' 3 | 4 | import introspection from './introspection' 5 | 6 | addEventListener('fetch', event => { 7 | event.respondWith(handleRequest(event)) 8 | }) 9 | 10 | async function digestMessage(message) { 11 | const msgUint8 = new TextEncoder().encode(message); // encode as (utf-8) Uint8Array 12 | const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8); // hash the message 13 | const hashArray = Array.from(new Uint8Array(hashBuffer)); // convert buffer to byte array 14 | const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join(''); // convert bytes to hex string 15 | return hashHex; 16 | } 17 | 18 | const handleGraphQLRequest = async event => { 19 | const { request } = event 20 | try { 21 | const { query, variables } = await request.json() 22 | const schema = await introspection(event) 23 | 24 | const queryDocument = parse(query) 25 | 26 | const cacheKey = await digestMessage(JSON.stringify(queryDocument)); 27 | const cachedQueryData = await GRAPHQL_STORE.get(cacheKey) 28 | if (cachedQueryData) { 29 | console.log('cached query') 30 | return new Response(cachedQueryData, {headers: { 'content-type': 'application/json' }}) 31 | } 32 | 33 | const errors = validate(schema, queryDocument) 34 | 35 | if (errors.length) { 36 | return new Response(JSON.stringify({ errors }), { status: 500 }) 37 | } 38 | 39 | const result = await rawRequest(ENDPOINT, query, variables) 40 | event.waitUntil(GRAPHQL_STORE.put(cacheKey, JSON.stringify(result), { expirationTtl: 60 })) 41 | return new Response(JSON.stringify(result), {headers: { 'content-type': 'application/json' }}) 42 | } catch (err) { 43 | console.log(err.message) 44 | return new Response("Error", { status: 500 }) 45 | } 46 | } 47 | 48 | async function handleRequest(event) { 49 | const url = new URL(event.request.url) 50 | 51 | if (url.pathname === "/graphql") { 52 | return handleGraphQLRequest(event) 53 | } else { 54 | return new Response(":)", { status: 200 }) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /introspection.js: -------------------------------------------------------------------------------- 1 | import { buildClientSchema, parse } from 'graphql' 2 | import { rawRequest } from 'graphql-request' 3 | 4 | const INTROSPECTION = ` 5 | query IntrospectionQuery { 6 | __schema { 7 | queryType { 8 | name 9 | __typename 10 | } 11 | mutationType { 12 | name 13 | __typename 14 | } 15 | subscriptionType { 16 | name 17 | __typename 18 | } 19 | types { 20 | ...FullType 21 | __typename 22 | } 23 | directives { 24 | name 25 | description 26 | locations 27 | args { 28 | ...InputValue 29 | __typename 30 | } 31 | __typename 32 | } 33 | __typename 34 | } 35 | } 36 | fragment FullType on __Type { 37 | kind 38 | name 39 | description 40 | fields(includeDeprecated: true) { 41 | name 42 | description 43 | args { 44 | ...InputValue 45 | __typename 46 | } 47 | type { 48 | ...TypeRef 49 | __typename 50 | } 51 | isDeprecated 52 | deprecationReason 53 | __typename 54 | } 55 | inputFields { 56 | ...InputValue 57 | __typename 58 | } 59 | interfaces { 60 | ...TypeRef 61 | __typename 62 | } 63 | enumValues(includeDeprecated: true) { 64 | name 65 | description 66 | isDeprecated 67 | deprecationReason 68 | __typename 69 | } 70 | possibleTypes { 71 | ...TypeRef 72 | __typename 73 | } 74 | __typename 75 | } 76 | fragment InputValue on __InputValue { 77 | name 78 | description 79 | type { 80 | ...TypeRef 81 | __typename 82 | } 83 | defaultValue 84 | __typename 85 | } 86 | fragment TypeRef on __Type { 87 | kind 88 | name 89 | ofType { 90 | kind 91 | name 92 | ofType { 93 | kind 94 | name 95 | ofType { 96 | kind 97 | name 98 | ofType { 99 | kind 100 | name 101 | ofType { 102 | kind 103 | name 104 | ofType { 105 | kind 106 | name 107 | ofType { 108 | kind 109 | name 110 | __typename 111 | } 112 | __typename 113 | } 114 | __typename 115 | } 116 | __typename 117 | } 118 | __typename 119 | } 120 | __typename 121 | } 122 | __typename 123 | } 124 | __typename 125 | } 126 | ` 127 | 128 | export default async evt => { 129 | const storedSchemaData = await GRAPHQL_STORE.get('schema') 130 | if (storedSchemaData) { 131 | const storedSchema = JSON.parse(storedSchemaData) 132 | console.log('cached schema hit') 133 | return buildClientSchema(storedSchema) 134 | } else { 135 | const { data } = await rawRequest(ENDPOINT, INTROSPECTION) 136 | evt.waitUntil(GRAPHQL_STORE.put('schema', JSON.stringify(data), { expirationTtl: 60 })) 137 | return buildClientSchema(data) 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "edge-proxy", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@types/zen-observable": { 8 | "version": "0.8.0", 9 | "resolved": "https://registry.npmjs.org/@types/zen-observable/-/zen-observable-0.8.0.tgz", 10 | "integrity": "sha512-te5lMAWii1uEJ4FwLjzdlbw3+n0FZNOvFXHxQDKeT0dilh7HOzdMzV2TrJVUzq8ep7J4Na8OUYPRLSQkJHAlrg==" 11 | }, 12 | "@wry/equality": { 13 | "version": "0.1.11", 14 | "resolved": "https://registry.npmjs.org/@wry/equality/-/equality-0.1.11.tgz", 15 | "integrity": "sha512-mwEVBDUVODlsQQ5dfuLUS5/Tf7jqUKyhKYHmVi4fPB6bDMOfWvUPJmKgS1Z7Za/sOI3vzWt4+O7yCiL/70MogA==", 16 | "requires": { 17 | "tslib": "^1.9.3" 18 | } 19 | }, 20 | "apollo-cache": { 21 | "version": "1.3.5", 22 | "resolved": "https://registry.npmjs.org/apollo-cache/-/apollo-cache-1.3.5.tgz", 23 | "integrity": "sha512-1XoDy8kJnyWY/i/+gLTEbYLnoiVtS8y7ikBr/IfmML4Qb+CM7dEEbIUOjnY716WqmZ/UpXIxTfJsY7rMcqiCXA==", 24 | "requires": { 25 | "apollo-utilities": "^1.3.4", 26 | "tslib": "^1.10.0" 27 | } 28 | }, 29 | "apollo-client": { 30 | "version": "2.6.10", 31 | "resolved": "https://registry.npmjs.org/apollo-client/-/apollo-client-2.6.10.tgz", 32 | "integrity": "sha512-jiPlMTN6/5CjZpJOkGeUV0mb4zxx33uXWdj/xQCfAMkuNAC3HN7CvYDyMHHEzmcQ5GV12LszWoQ/VlxET24CtA==", 33 | "requires": { 34 | "@types/zen-observable": "^0.8.0", 35 | "apollo-cache": "1.3.5", 36 | "apollo-link": "^1.0.0", 37 | "apollo-utilities": "1.3.4", 38 | "symbol-observable": "^1.0.2", 39 | "ts-invariant": "^0.4.0", 40 | "tslib": "^1.10.0", 41 | "zen-observable": "^0.8.0" 42 | } 43 | }, 44 | "apollo-link": { 45 | "version": "1.2.14", 46 | "resolved": "https://registry.npmjs.org/apollo-link/-/apollo-link-1.2.14.tgz", 47 | "integrity": "sha512-p67CMEFP7kOG1JZ0ZkYZwRDa369w5PIjtMjvrQd/HnIV8FRsHRqLqK+oAZQnFa1DDdZtOtHTi+aMIW6EatC2jg==", 48 | "requires": { 49 | "apollo-utilities": "^1.3.0", 50 | "ts-invariant": "^0.4.0", 51 | "tslib": "^1.9.3", 52 | "zen-observable-ts": "^0.8.21" 53 | } 54 | }, 55 | "apollo-utilities": { 56 | "version": "1.3.4", 57 | "resolved": "https://registry.npmjs.org/apollo-utilities/-/apollo-utilities-1.3.4.tgz", 58 | "integrity": "sha512-pk2hiWrCXMAy2fRPwEyhvka+mqwzeP60Jr1tRYi5xru+3ko94HI9o6lK0CT33/w4RDlxWchmdhDCrvdr+pHCig==", 59 | "requires": { 60 | "@wry/equality": "^0.1.2", 61 | "fast-json-stable-stringify": "^2.0.0", 62 | "ts-invariant": "^0.4.0", 63 | "tslib": "^1.10.0" 64 | } 65 | }, 66 | "fast-json-stable-stringify": { 67 | "version": "2.1.0", 68 | "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", 69 | "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" 70 | }, 71 | "prettier": { 72 | "version": "1.19.1", 73 | "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", 74 | "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", 75 | "dev": true 76 | }, 77 | "symbol-observable": { 78 | "version": "1.2.0", 79 | "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", 80 | "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==" 81 | }, 82 | "ts-invariant": { 83 | "version": "0.4.4", 84 | "resolved": "https://registry.npmjs.org/ts-invariant/-/ts-invariant-0.4.4.tgz", 85 | "integrity": "sha512-uEtWkFM/sdZvRNNDL3Ehu4WVpwaulhwQszV8mrtcdeE8nN00BV9mAmQ88RkrBhFgl9gMgvjJLAQcZbnPXI9mlA==", 86 | "requires": { 87 | "tslib": "^1.9.3" 88 | } 89 | }, 90 | "tslib": { 91 | "version": "1.13.0", 92 | "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz", 93 | "integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==" 94 | }, 95 | "zen-observable": { 96 | "version": "0.8.15", 97 | "resolved": "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.15.tgz", 98 | "integrity": "sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ==" 99 | }, 100 | "zen-observable-ts": { 101 | "version": "0.8.21", 102 | "resolved": "https://registry.npmjs.org/zen-observable-ts/-/zen-observable-ts-0.8.21.tgz", 103 | "integrity": "sha512-Yj3yXweRc8LdRMrCC8nIc4kkjWecPAUVh0TI0OUrWXx6aX790vLcDlWca6I4vsyCGH3LpWxq0dJRcMOFoVqmeg==", 104 | "requires": { 105 | "tslib": "^1.9.3", 106 | "zen-observable": "^0.8.0" 107 | } 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "edge-proxy", 4 | "version": "1.0.0", 5 | "description": "A template for kick starting a Cloudflare Workers project", 6 | "main": "index.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1", 9 | "format": "prettier --write '**/*.{js,css,json,md}'" 10 | }, 11 | "author": "Kristian Freeman ", 12 | "license": "MIT", 13 | "devDependencies": { 14 | "prettier": "^1.18.2" 15 | }, 16 | "dependencies": { 17 | "graphql": "^15.0.0", 18 | "graphql-request": "^1.8.2", 19 | "graphql-tag": "^2.10.3" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /wrangler.toml: -------------------------------------------------------------------------------- 1 | name = "edge-proxy" 2 | type = "webpack" 3 | account_id = "dc56444c4c955a1653106ccf997c1067" 4 | workers_dev = true 5 | 6 | vars = { ENDPOINT = "https://cf-workers-hasura-integration.herokuapp.com/v1/graphql" } 7 | kv-namespaces = [ 8 | { binding = "GRAPHQL_STORE", id = "c6c38d73474e493fa8e341d175b45a87" } 9 | ] 10 | -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | cross-fetch@2.2.2: 6 | version "2.2.2" 7 | resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-2.2.2.tgz#a47ff4f7fc712daba8f6a695a11c948440d45723" 8 | integrity sha1-pH/09/xxLauo9qaVoRyUhEDUVyM= 9 | dependencies: 10 | node-fetch "2.1.2" 11 | whatwg-fetch "2.0.4" 12 | 13 | graphql-request@^1.8.2: 14 | version "1.8.2" 15 | resolved "https://registry.yarnpkg.com/graphql-request/-/graphql-request-1.8.2.tgz#398d10ae15c585676741bde3fc01d5ca948f8fbe" 16 | integrity sha512-dDX2M+VMsxXFCmUX0Vo0TopIZIX4ggzOtiCsThgtrKR4niiaagsGTDIHj3fsOMFETpa064vzovI+4YV4QnMbcg== 17 | dependencies: 18 | cross-fetch "2.2.2" 19 | 20 | graphql-tag@^2.10.3: 21 | version "2.10.3" 22 | resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.10.3.tgz#ea1baba5eb8fc6339e4c4cf049dabe522b0edf03" 23 | integrity sha512-4FOv3ZKfA4WdOKJeHdz6B3F/vxBLSgmBcGeAFPf4n1F64ltJUvOOerNj0rsJxONQGdhUMynQIvd6LzB+1J5oKA== 24 | 25 | graphql@^15.0.0: 26 | version "15.0.0" 27 | resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.0.0.tgz#042a5eb5e2506a2e2111ce41eb446a8e570b8be9" 28 | integrity sha512-ZyVO1xIF9F+4cxfkdhOJINM+51B06Friuv4M66W7HzUOeFd+vNzUn4vtswYINPi6sysjf1M2Ri/rwZALqgwbaQ== 29 | 30 | node-fetch@2.1.2: 31 | version "2.1.2" 32 | resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.1.2.tgz#ab884e8e7e57e38a944753cec706f788d1768bb5" 33 | integrity sha1-q4hOjn5X44qUR1POxwb3iNF2i7U= 34 | 35 | prettier@^1.18.2: 36 | version "1.19.1" 37 | resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb" 38 | integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== 39 | 40 | whatwg-fetch@2.0.4: 41 | version "2.0.4" 42 | resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f" 43 | integrity sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng== 44 | --------------------------------------------------------------------------------