Skip to content

fix: verbatimModuleSyntax #953

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

Merged
merged 1 commit into from
Jul 1, 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
4 changes: 2 additions & 2 deletions src/layers/2_generator/__snapshots__/files.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export const isError = <$Value>(value: $Value): value is Include<$Value, ErrorOb
`;

exports[`schema2 5`] = `
"import { ResultSet, SelectionSet } from '../../../../src/entrypoints/alpha/schema.js'
import { Index } from './Index.js'
"import type { ResultSet, SelectionSet } from '../../../../src/entrypoints/alpha/schema.js'
import type { Index } from './Index.js'

// Runtime
// -------
Expand Down
12 changes: 6 additions & 6 deletions src/layers/2_generator/code/Error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ export const { generate: generateError, moduleName: moduleNameError } = createCo
)

code.push(`
const ErrorObjectsTypeNameSelectedEnum = {
${config.error.objects.map(_ => `${_.name}: { __typename: '${_.name}' }`).join(`,\n`)}
} as ${config.error.objects.length > 0 ? `const` : `Record<string,ObjectWithTypeName>`}
const ErrorObjectsTypeNameSelectedEnum = {
${config.error.objects.map(_ => `${_.name}: { __typename: '${_.name}' }`).join(`,\n`)}
} as ${config.error.objects.length > 0 ? `const` : `Record<string,ObjectWithTypeName>`}

const ErrorObjectsTypeNameSelected = Object.values(ErrorObjectsTypeNameSelectedEnum)
const ErrorObjectsTypeNameSelected = Object.values(ErrorObjectsTypeNameSelectedEnum)

type ErrorObjectsTypeNameSelected = (typeof ErrorObjectsTypeNameSelected)[number]
`)
type ErrorObjectsTypeNameSelected = (typeof ErrorObjectsTypeNameSelected)[number]
`)

code.push(
`export const isError = <$Value>(value:$Value): value is Include<$Value, ErrorObjectsTypeNameSelected> => {
Expand Down
4 changes: 2 additions & 2 deletions src/layers/2_generator/code/Select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export const { generate: generateSelect, moduleName: moduleNameSelect } = create
(config) => {
const code: string[] = []

code.push(`import { Index } from './${moduleNameIndex}.js'`)
code.push(`import { SelectionSet, ResultSet } from '${config.libraryPaths.schema}'`)
code.push(`import type { Index } from './${moduleNameIndex}.js'`)
code.push(`import type { SelectionSet, ResultSet } from '${config.libraryPaths.schema}'`)
code.push(``)

code.push(
Expand Down
2 changes: 1 addition & 1 deletion src/layers/2_generator/code/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const { moduleName: moduleNameGlobal, generate: generateGlobal } = create
const code: string[] = []

code.push(
`import { Index } from './${moduleNameIndex}.js'`,
`import type { Index } from './${moduleNameIndex}.js'`,
)

if (config.typeMapByKind.GraphQLScalarTypeCustom.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion tests/_/schema/generated/Global.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Index } from './Index.js'
import type { Index } from './Index.js'

import type * as CustomScalar from '../../customScalarCodecs.js'

Expand Down
4 changes: 2 additions & 2 deletions tests/_/schema/generated/Select.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ResultSet, SelectionSet } from '../../../../src/entrypoints/alpha/schema.js'
import { Index } from './Index.js'
import type { ResultSet, SelectionSet } from '../../../../src/entrypoints/alpha/schema.js'
import type { Index } from './Index.js'

// Runtime
// -------
Expand Down
2 changes: 1 addition & 1 deletion tests/_/schemaMutationOnly/generated/Global.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Index } from './Index.js'
import type { Index } from './Index.js'

declare global {
export namespace GraphQLRequestTypes {
Expand Down
4 changes: 2 additions & 2 deletions tests/_/schemaMutationOnly/generated/Select.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ResultSet, SelectionSet } from '../../../../src/entrypoints/alpha/schema.js'
import { Index } from './Index.js'
import type { ResultSet, SelectionSet } from '../../../../src/entrypoints/alpha/schema.js'
import type { Index } from './Index.js'

// Runtime
// -------
Expand Down
2 changes: 1 addition & 1 deletion tests/_/schemaQueryOnly/generated/Global.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Index } from './Index.js'
import type { Index } from './Index.js'

declare global {
export namespace GraphQLRequestTypes {
Expand Down
4 changes: 2 additions & 2 deletions tests/_/schemaQueryOnly/generated/Select.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ResultSet, SelectionSet } from '../../../../src/entrypoints/alpha/schema.js'
import { Index } from './Index.js'
import type { ResultSet, SelectionSet } from '../../../../src/entrypoints/alpha/schema.js'
import type { Index } from './Index.js'

// Runtime
// -------
Expand Down