Skip to content

Commit

Permalink
refactor: move client layer above core (#967)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt authored Jul 5, 2024
1 parent ee3781d commit 8efd3b2
Show file tree
Hide file tree
Showing 28 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/entrypoints/alpha/_Graffle.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from '../../layers/5_client/client.js'
export * from '../../layers/6_client/client.js'
export * as Scalars from './scalars.js'
2 changes: 1 addition & 1 deletion src/entrypoints/alpha/client.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { Client, create, createPrefilled, Input, InputPrefilled } from '../../layers/5_client/client.js'
export { create as createSelect, select } from '../../layers/5_select/select.js'
export { Client, create, createPrefilled, Input, InputPrefilled } from '../../layers/6_client/client.js'
2 changes: 1 addition & 1 deletion src/layers/0_functions/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { StandardScalarVariables } from '../../lib/graphql.js'
import type { DocumentInput, OperationNameInput } from '../5_client/types.js'
import type { DocumentInput, OperationNameInput } from '../6_client/types.js'

export interface BaseInput {
document: DocumentInput
Expand Down
2 changes: 1 addition & 1 deletion src/layers/3_SelectionSet/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { RootTypeName } from '../../lib/graphql.js'
import { assertArray, assertObject, lowerCaseFirstLetter } from '../../lib/prelude.js'
import { Schema } from '../1_Schema/__.js'
import { readMaybeThunk } from '../1_Schema/core/helpers.js'
import type { ReturnModeType } from '../5_client/Config.js'
import type { ReturnModeType } from '../6_client/Config.js'
import type { SelectionSet } from './__.js'
import { isSelectFieldName } from './helpers.js'
import { parseClientDirectiveDefer } from './runtime/directives/defer.js'
Expand Down
2 changes: 1 addition & 1 deletion src/layers/5_core/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Schema } from '../1_Schema/__.js'
import type { Config } from '../5_client/Config.js'
import type { Config } from '../6_client/Config.js'

export type Transport = TransportMemory | TransportHttp

Expand Down
2 changes: 1 addition & 1 deletion src/layers/5_createExtension/createExtension.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import type { Extension } from '../5_client/client.js'
import type { Extension } from '../6_client/client.js'

export const createExtension = (input: Extension) => input
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { oops } from '../../lib/anyware/specHelpers.js'
const client = Graffle.create({ schema: 'https://foo', returnMode: 'dataAndErrors' })
const headers = { 'x-foo': 'bar' }

// todo each extension added should copy, not mutate the client
test('using an extension returns a copy of the client', () => {
const client2 = client.use(async () => {})
expect(client2 !== client).toBe(true)
})

describe(`entrypoint pack`, () => {
test(`can add header`, async ({ fetch }) => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Graffle } from '../../../entrypoints/alpha/main.js'
import { Upload } from './Upload.js'

import { createYoga } from 'graphql-yoga'
import type { Client } from '../../5_client/client.js'
import type { Client } from '../../6_client/client.js'

let server: Server
let port: number
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/_/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface Fixtures {
}

import { Graffle } from '../../src/entrypoints/alpha/main.js'
import type { Client } from '../../src/layers/5_client/client.js'
import type { Client } from '../../src/layers/6_client/client.js'

export const test = testBase.extend<Fixtures>({
// @ts-expect-error https://github.com/vitest-dev/vitest/discussions/5710
Expand Down

0 comments on commit 8efd3b2

Please sign in to comment.