Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move client layer above core #967

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
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.
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
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