Skip to content

Commit

Permalink
chore!: rename export
Browse files Browse the repository at this point in the history
  • Loading branch information
Teages committed Jul 2, 2024
1 parent d1b7070 commit 45a3611
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DefineSchema, Schemas, UserSchemaTypes } from '../schema'
import type { GqfPackage } from '../utils/package'
import type { Package } from '../utils/package'
import { $enum, gqf, gqp } from '../core'

export { sync, type Output } from './sync'
Expand All @@ -14,7 +14,7 @@ export type LoadFromUrl<T extends string> =

export function useSchema<T extends string>(
_url?: T,
): GqfPackage<LoadFromUrl<T>> {
): Package<LoadFromUrl<T>> {
return { gqf, gqp, $enum } as any
}
export type { GqfPackage }
export type { Package as GqfPackage }
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { $enum, gqf, gqp } from './core'
import type { DefineGqf } from './utils/package'
import type { CreateGqf } from './utils/package'

export { $enum } from './core'
export type { RequireQueryPart, ResultOf, VariablesOf } from './typed'

export const defineGqf: DefineGqf = () => ({ gqf, gqp, $enum }) as any
export const createGqf: CreateGqf = () => ({ gqf, gqp, $enum }) as any
export { useSchema } from './cli'
6 changes: 3 additions & 3 deletions src/utils/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import type { $enum, gqf, gqp } from '../core'
import type { DefineSchema, UserSchemaTypes } from '../schema'
import type { GraphQueryFunction, GraphQueryPartial } from '../typed'

export interface DefineGqf {
<Schema extends UserSchemaTypes | undefined = undefined>(): GqfPackage<Schema>
export interface CreateGqf {
<Schema extends UserSchemaTypes | undefined = undefined>(): Package<Schema>
}

export type GqfPackage<Schema extends UserSchemaTypes | DefineSchema<any> | undefined> =
export type Package<Schema extends UserSchemaTypes | DefineSchema<any> | undefined> =
Schema extends UserSchemaTypes | DefineSchema<any>
? {
$enum: typeof $enum
Expand Down
4 changes: 2 additions & 2 deletions test/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { describe, expect, it } from 'vitest'
import { $enum, defineGqf } from '../src'
import { $enum, createGqf } from '../src'

describe('@teages/gqf', () => {
it('works', () => {
const p = defineGqf()
const p = createGqf()
expect(typeof p.gqf).toBe('function')
expect(typeof p.gqp).toBe('function')
expect(typeof p.$enum).toBe('function')
Expand Down
4 changes: 2 additions & 2 deletions test/typed/index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { describe, expectTypeOf, test } from 'vitest'
import { defineGqf } from '../../src'
import { createGqf } from '../../src'
import type { RequireQueryPart } from '../../src'
import type { TypedQueryDocumentNode } from '../../src/typed'
import type { CategoryEnum, Schema } from './fixture/schema'

describe('type', () => {
const { gqf, gqp, $enum } = defineGqf<Schema>()
const { gqf, gqp, $enum } = createGqf<Schema>()

test('simple', () => {
const query = gqf(['__typename'])
Expand Down

0 comments on commit 45a3611

Please sign in to comment.