tql icon indicating copy to clipboard operation
tql copied to clipboard

Support importing generated code from `@timkendall/tql`

Open timkendall opened this issue 3 years ago • 2 comments

Follow the @prisma/client approach as it is a nice DX.

We could expose this as a codegen option w/this being the default (to generate to a non-default location we could take a --output flag).

(Possible) Default Workflow

  1. yarn install @timkendall/tql
  2. Post-install hook looks for a .graphqlconfig or apollo.config.js to discover schema and runs codegen
  3. Generated code is stored in node_modules/@timkendall/tql/.tql/client
  4. User imports their generated code from the module i.e import { query, } from '@timkendall/tql'

(Possible) Custom Workflow (for users who are using tql to generate published SDKs or need more control)

  1. yarn install @timkendall/tql
  2. Manually execute codegen yarn tql <schema> > sdk.ts OR yarn tql <schema> --sdk (interactive prompt?)

image

timkendall avatar Jan 23 '22 05:01 timkendall

Please note that this is incompatible with Yarn 2+. There's a discussion at https://github.com/prisma/prisma/issues/1439.

ivasilov avatar Feb 02 '22 11:02 ivasilov

Ah I did not know that, thanks for the heads up. Yeah may not be the best idea to do something non-standard like that (though the developer experience is fairly nice).

timkendall avatar Feb 09 '22 04:02 timkendall