tql
tql copied to clipboard
Compiler plugin
As a runtime optimization it would be nice to have compiler plugins for TypeScript, Babel, ESBuild, etc. to replace the function invocations with static query text (to avoid both the cost of DSL function calls and GraphQL AST serialization).
We would need to account for cases where users are doing "bad things" and dynamically generating queries (perhaps a linter plugin and/or warning emitted from the compiler could be solutions).
We could also experiment with support for "Build-time APQ's"; i.e replace query text with a SHA and export operations to be pre-registered/whitelisted with an API server.
Examples: -https://github.com/xialvjun/ts-sql-plugin -https://dev.doctorevidence.com/how-to-write-a-typescript-transform-plugin-fc5308fdd943
- https://github.com/facebook/relay/tree/main/compiler
Not to support this we will want to support Variable Definitions (otherwise we can't statically derive the checksum of operations with variables).
https://github.com/apollographql/persistgraphql/blob/master/src/extractFromJS.ts
https://github.com/apollographql/apollo-link-persisted-queries/blob/master/src/index.ts#L120
https://www.apollographql.com/blog/announcement/platform/improve-graphql-performance-with-automatic-persisted-queries/
- https://github.com/Caligatio/jsSHA
- https://github.com/pierrec/js-xxhash
- https://github.com/sindresorhus/crypto-hash
- https://github.com/jungomi/xxhash-wasm
https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API
https://www.apollographql.com/docs/react/api/link/persisted-queries/
https://github.com/Quramy/ts-graphql-plugin/tree/main/src
https://github.com/Effect-TS/core/tree/master/packages/tracing-plugin