tql icon indicating copy to clipboard operation
tql copied to clipboard

Compiler plugin

Open timkendall opened this issue 4 years ago • 9 comments

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

timkendall avatar Feb 14 '21 11:02 timkendall

Not to support this we will want to support Variable Definitions (otherwise we can't statically derive the checksum of operations with variables).

timkendall avatar Feb 16 '21 00:02 timkendall

https://github.com/apollographql/persistgraphql/blob/master/src/extractFromJS.ts

timkendall avatar Sep 13 '21 01:09 timkendall

https://github.com/apollographql/apollo-link-persisted-queries/blob/master/src/index.ts#L120

timkendall avatar Sep 13 '21 01:09 timkendall

https://www.apollographql.com/blog/announcement/platform/improve-graphql-performance-with-automatic-persisted-queries/

timkendall avatar Sep 13 '21 01:09 timkendall

  • https://github.com/Caligatio/jsSHA
  • https://github.com/pierrec/js-xxhash
  • https://github.com/sindresorhus/crypto-hash
  • https://github.com/jungomi/xxhash-wasm

timkendall avatar Sep 13 '21 01:09 timkendall

https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API

timkendall avatar Nov 16 '21 16:11 timkendall

https://www.apollographql.com/docs/react/api/link/persisted-queries/

timkendall avatar Nov 16 '21 16:11 timkendall

https://github.com/Quramy/ts-graphql-plugin/tree/main/src

timkendall avatar Nov 17 '21 15:11 timkendall

https://github.com/Effect-TS/core/tree/master/packages/tracing-plugin

timkendall avatar Nov 17 '21 16:11 timkendall