generated from mizdra/npm-package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from mizdra/fix-composite-bug
Fix compile errors caused by `--composite` of TypeScript
- Loading branch information
Showing
8 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Options required to reproduce https://github.com/mizdra/graphql-codegen-typescript-fabbrica/issues/85 | ||
install-links=true | ||
package-lock=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { CodegenConfig } from '@graphql-codegen/cli'; | ||
|
||
const config: CodegenConfig = { | ||
schema: './schema.graphql', | ||
generates: { | ||
// The files other than those matching includes cannot be read when using `compisite`. | ||
// Therefore, fabbrica artifacts are also output under `src/`. | ||
'src/__generated__/types.ts': { | ||
plugins: ['typescript'], | ||
config: { | ||
enumsAsTypes: true, // required | ||
avoidOptionals: true, // required | ||
}, | ||
}, | ||
'src/__generated__/fabbrica.ts': { | ||
plugins: ['@mizdra/graphql-codegen-typescript-fabbrica'], | ||
config: { | ||
typesFile: './types.js', // required | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "e2e-composite", | ||
"type": "module", | ||
"scripts": { | ||
"start": "run-s clean _install gen build", | ||
"clean": "node -e \"require('fs').rmSync('node_modules', { recursive: true, force: true })\"", | ||
"_install": "npm install", | ||
"gen": "graphql-codegen-esm", | ||
"build": "tsc" | ||
}, | ||
"engines": { | ||
"node": ">=18.0.0" | ||
}, | ||
"dependencies": { | ||
"@mizdra/graphql-codegen-typescript-fabbrica": "../.." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
type Book { | ||
id: ID! | ||
title: String! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { defineBookFactory, dynamic } from './__generated__/fabbrica.js'; | ||
|
||
export const BookFactory = defineBookFactory({ | ||
defaultFields: { | ||
__typename: 'Book', | ||
id: dynamic(({ seq }) => `Book-${seq}`), | ||
title: 'Yuyushiki', | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["./src"], | ||
"exclude": ["node_modules"], | ||
"compilerOptions": { | ||
"composite": true, | ||
"declaration": true, | ||
"noEmit": false, | ||
"outDir": "dist", | ||
"rootDir": "src" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
export { dynamic } from './field-resolver.js'; | ||
export { dynamic, Dynamic } from './field-resolver.js'; | ||
export { resetAllSequence, resetSequence } from './sequence.js'; | ||
export { DefineTypeFactoryInterface, DefineTypeFactoryInterfaceRequired, defineTypeFactory } from './factory.js'; | ||
export { | ||
DefineTypeFactoryInterface, | ||
DefineTypeFactoryInterfaceRequired, | ||
defineTypeFactory, | ||
Traits, | ||
TypeFactoryInterface, | ||
} from './factory.js'; |