Skip to content

Commit

Permalink
feat(graffle): incremental typed client (#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt authored May 11, 2024
1 parent a1e95fa commit eecf7b9
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 130 deletions.
1 change: 1 addition & 0 deletions src/entrypoints/alpha/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * as Graffle from '../../layers/5_client/client.js'
7 changes: 0 additions & 7 deletions src/layers/3_SelectionSet/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ export interface Context {
schemaIndex: Schema.Index
config: {
returnMode: ReturnModeType
// typeHooks: {
// /**
// * Control encoding for custom scalars
// * found in inputs.
// */
// customScalar: (v: Schema.Scalar.Scalar) => Schema.Scalar.StandardScalarRuntimeTypes
// }
}
}

Expand Down
23 changes: 23 additions & 0 deletions src/layers/5_client/client.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { describe, expect, test } from 'vitest'
import { Graffle } from '../../entrypoints/alpha/main.js'

describe(`without schemaIndex only raw is available`, () => {
const schema = new URL(`https://foo.io/api/graphql`)
const graffle = Graffle.create({ schema })

test(`unavailable methods`, () => {
// @ts-expect-error
expect(graffle.document).toBeUndefined()
// @ts-expect-error
expect(graffle.query).toBeUndefined()
// @ts-expect-error
expect(graffle.subscription).toBeUndefined()
// @ts-expect-error
expect(graffle.mutation).toBeUndefined()
})

test(`available methods`, () => {
expect(graffle.raw).toBeTypeOf(`function`)
expect(graffle.rawOrThrow).toBeTypeOf(`function`)
})
})
Loading

0 comments on commit eecf7b9

Please sign in to comment.