From 6813a65395bacf02d1a81df50f91317ef3dec1ca Mon Sep 17 00:00:00 2001 From: Tim Kendall Date: Thu, 25 Nov 2021 13:25:24 -0800 Subject: [PATCH] Correctly build GraphQLSchema object in generated SDK --- CURRENT_LIMITATIONS.md | 2 ++ codegen/package.json | 2 +- codegen/src/render.ts | 14 +++++++++----- package.json | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CURRENT_LIMITATIONS.md b/CURRENT_LIMITATIONS.md index 574b4a9..c79ac09 100644 --- a/CURRENT_LIMITATIONS.md +++ b/CURRENT_LIMITATIONS.md @@ -10,6 +10,8 @@ - [x] Rewrite `Result` and `Variable` types - [x] Type-level testing - [x] Default unknown scalars to `string`'s +- [ ] Fix nested variable extraction +- [ ] Dynamic selector building (using Proxy's) - [ ] Restricing `Selection`'s in selector function returns - [ ] Finish rewriting unit tests - [ ] Field alias support diff --git a/codegen/package.json b/codegen/package.json index 6a1249a..01f93fa 100644 --- a/codegen/package.json +++ b/codegen/package.json @@ -1,6 +1,6 @@ { "name": "@timkendall/tql-gen", - "version": "1.0.0-rc.1", + "version": "1.0.0-rc.2", "description": "Code generator for @timkendall/tql.", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/codegen/src/render.ts b/codegen/src/render.ts index 9e213b5..8657675 100644 --- a/codegen/src/render.ts +++ b/codegen/src/render.ts @@ -5,7 +5,7 @@ import prettier from "prettier"; import { typeTransform, selectorInterfaceTransform } from "./transforms"; export const render = (sdl: string): string => { - const ast = parse(sdl); + const ast = parse(sdl, { noLocation: true }); const schema = buildSchema(sdl); const transforms = [ @@ -35,7 +35,10 @@ export const render = (sdl: string): string => { `; const source = - `import { + ` + import { buildASTSchema } from 'graphql' + + import { TypeConditionError, NamedType, Field, @@ -50,12 +53,13 @@ export const render = (sdl: string): string => { inlineFragment, argument, selectionSet - } from './src' + } from '@timkendall/tql' + + export { Result, Variables, $ } from '@timkendall/tql' - export { Result, Variables, $ } from './src' ` + ` - export const SCHEMA = ${JSON.stringify(ast)} + export const SCHEMA = buildASTSchema(${JSON.stringify(ast)}) export const ENUMS = ${ENUMS} ` + diff --git a/package.json b/package.json index 602ba6c..bc4fdc4 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@timkendall/tql", "author": "Timothy Kendall", "license": "MIT", - "version": "1.0.0-rc.1", + "version": "1.0.0-rc.2", "description": "Write GraphQL queries in TypeScript.", "sideEffects": false, "keywords": [