Skip to content

Commit

Permalink
feat: do not fail on unsupported types (#201)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
zigomir and ctison authored Apr 16, 2023
1 parent 3bb36d3 commit 9e66c5f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
pnpm run build
pnpm run gen:rickandmorty
pnpm run test:rickandmorty
pnpm run gen:anilist
- name: Compute package version
id: version
Expand Down
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,12 @@
},
"files.eol": "\n",
"files.insertFinalNewline": true,
"cSpell.words": ["codegen", "pnpm", "nvmrc", "rickandmorty", "liquidjs"]
"cSpell.words": [
"anilist",
"codegen",
"liquidjs",
"nvmrc",
"pnpm",
"rickandmorty"
]
}
11 changes: 11 additions & 0 deletions graphql.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@ projects:
plugins:
- packages/graphql-codegen-golang/dist/index.js:
packageName: rickandmorty
anilist:
schema: https://graphql.anilist.co
extensions:
codegen:
generates:
examples/anilist/graphql.go:
hooks:
afterOneFileWrite: go fmt
plugins:
- packages/graphql-codegen-golang/dist/index.js:
packageName: anilist
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"build": "turbo run build",
"format": "prettier --write .",
"gen": "graphql-codegen",
"gen:anilist": "pnpm run gen -p anilist",
"gen:rickandmorty": "pnpm run gen -p rickandmorty",
"lint": "turbo run lint",
"prepare": "husky install",
Expand Down
5 changes: 3 additions & 2 deletions packages/graphql-codegen-golang/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class GolangGenerator {
prefix: string = '',
nonNull: boolean = false
): string {
if (type.kind === 'NamedType') {
if (type.kind === 'NamedType' && this.types[type.name.value]) {
return [
`${nonNull ? '' : '*'}${prefix}`,
`${this.types[type.name.value]} `,
Expand All @@ -267,7 +267,8 @@ export class GolangGenerator {
nonNull
)
}
throw new Error(`field type "${type}" not supported!`)
console.debug(`Skipped unsupported field type "${type.name.value}"`)
return ''
}

/**
Expand Down

0 comments on commit 9e66c5f

Please sign in to comment.