Skip to content
Open
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
3 changes: 2 additions & 1 deletion examples/$/graffle/modules/client.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Create } from 'graffle/client'
import { DocumentBuilder } from 'graffle/extensions/document-builder'
import { TransportHttp } from 'graffle/extensions/transport-http'
import * as $$Utilities from 'graffle/utilities-for-generated'
Expand Down Expand Up @@ -50,4 +51,4 @@ const context = $$Utilities.pipe(
* const result = await client.query.pokemon({ name: true })
* ```
*/
export const create = $$Utilities.createConstructorWithContext(context)
export const create: Create<typeof context> = $$Utilities.createConstructorWithContext(context)
15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,20 @@
"./extensions/schema-errors": "./build/exports/extensions/schema-errors/runtime.js",
"./extensions/transport-http": "./build/exports/extensions/transport-http/runtime.js",
"./extensions/transport-memory": "./build/exports/extensions/transport-memory/runtime.js",
"./extensions/upload": "./build/exports/extensions/upload/runtime.js"
"./extensions/upload": "./build/exports/extensions/upload/runtime.js",
"./build/client/client.js": "./build/client/client.js",
"./build/client/handle.js": "./build/client/handle.js",
"./build/context/fragments/configuration/check/check.js": "./build/context/fragments/configuration/check/check.js",
"./build/context/fragments/configuration/fragment.js": "./build/context/fragments/configuration/fragment.js",
"./build/context/fragments/configuration/output/configuration.js": "./build/context/fragments/configuration/output/configuration.js",
"./build/context/fragments/configuration/schema/configuration.js": "./build/context/fragments/configuration/schema/configuration.js",
"./build/context/fragments/extensions/fragment.js": "./build/context/fragments/extensions/fragment.js",
"./build/context/fragments/properties/fragment.js": "./build/context/fragments/properties/fragment.js",
"./build/context/fragments/requestInterceptors/helpers.js": "./build/context/fragments/requestInterceptors/helpers.js",
"./build/context/fragments/transports/dataType/data.js": "./build/context/fragments/transports/dataType/data.js",
"./build/context/fragments/transports/__.js": "./build/context/fragments/transports/__.js",
"./build/client/methods/gql/DocumentSender.js": "./build/client/methods/gql/DocumentSender.js",
"./build/lib/graphql-kit/document/__.js": "./build/lib/graphql-kit/document/__.js"
},
"files": [
"build",
Expand Down
2 changes: 1 addition & 1 deletion src/exports/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { type Client, create } from '#src/client/client.js'
export { type Client, type Create, create } from '#src/client/client.js'
export { Var } from '#src/lib/graphql-kit/document/__.js'
export { create as createSelect, select } from '#src/select/select.js'
// TODO remove this hacky export
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Create } from '#graffle/client'
import { DocumentBuilder } from '#graffle/extensions/document-builder'
import { TransportHttp } from '#graffle/extensions/transport-http'
import * as $$Utilities from '#graffle/utilities-for-generated'
Expand Down Expand Up @@ -49,4 +50,4 @@ const context = $$Utilities.pipe(
* const result = await client.query.pokemon({ name: true })
* ```
*/
export const create = $$Utilities.createConstructorWithContext(context)
export const create: Create<typeof context> = $$Utilities.createConstructorWithContext(context)
9 changes: 8 additions & 1 deletion src/generator/generators/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ export const ModuleGeneratorClient = createModuleGenerator(
from: config.paths.imports.grafflePackage.extensionDocumentBuilder,
}),
)
code(
Syn.TS.importNamed({
names: 'Create',
from: config.paths.imports.grafflePackage.client,
type: true,
}),
)

code`
const context = ${$.$$Utilities}.pipe(
Expand Down Expand Up @@ -77,7 +84,7 @@ export const ModuleGeneratorClient = createModuleGenerator(
* const result = await client.query.pokemon({ name: true })
* \`\`\`
*/
export const create = ${$.$$Utilities}.createConstructorWithContext(context)
export const create: Create<typeof context> = ${$.$$Utilities}.createConstructorWithContext(context)
`
},
)