Skip to content

Commit 9e66c5f

Browse files
zigomirctison
andauthored
feat: do not fail on unsupported types (#201)
* Add `skipUnsupportedTypes` to the config Skip and silence the error if set to `true`. * feat: do not fail on unsupported types --------- Co-authored-by: Charles Tison <[email protected]>
1 parent 3bb36d3 commit 9e66c5f

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

.github/workflows/cicd.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
pnpm run build
3737
pnpm run gen:rickandmorty
3838
pnpm run test:rickandmorty
39+
pnpm run gen:anilist
3940
4041
- name: Compute package version
4142
id: version

.vscode/settings.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,12 @@
1414
},
1515
"files.eol": "\n",
1616
"files.insertFinalNewline": true,
17-
"cSpell.words": ["codegen", "pnpm", "nvmrc", "rickandmorty", "liquidjs"]
17+
"cSpell.words": [
18+
"anilist",
19+
"codegen",
20+
"liquidjs",
21+
"nvmrc",
22+
"pnpm",
23+
"rickandmorty"
24+
]
1825
}

graphql.config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,14 @@ projects:
2323
plugins:
2424
- packages/graphql-codegen-golang/dist/index.js:
2525
packageName: rickandmorty
26+
anilist:
27+
schema: https://graphql.anilist.co
28+
extensions:
29+
codegen:
30+
generates:
31+
examples/anilist/graphql.go:
32+
hooks:
33+
afterOneFileWrite: go fmt
34+
plugins:
35+
- packages/graphql-codegen-golang/dist/index.js:
36+
packageName: anilist

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"build": "turbo run build",
55
"format": "prettier --write .",
66
"gen": "graphql-codegen",
7+
"gen:anilist": "pnpm run gen -p anilist",
78
"gen:rickandmorty": "pnpm run gen -p rickandmorty",
89
"lint": "turbo run lint",
910
"prepare": "husky install",

packages/graphql-codegen-golang/src/generator.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export class GolangGenerator {
244244
prefix: string = '',
245245
nonNull: boolean = false
246246
): string {
247-
if (type.kind === 'NamedType') {
247+
if (type.kind === 'NamedType' && this.types[type.name.value]) {
248248
return [
249249
`${nonNull ? '' : '*'}${prefix}`,
250250
`${this.types[type.name.value]} `,
@@ -267,7 +267,8 @@ export class GolangGenerator {
267267
nonNull
268268
)
269269
}
270-
throw new Error(`field type "${type}" not supported!`)
270+
console.debug(`Skipped unsupported field type "${type.name.value}"`)
271+
return ''
271272
}
272273

273274
/**

0 commit comments

Comments
 (0)