-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: parameterize generation of the HTTP client
- Loading branch information
Showing
30 changed files
with
1,032 additions
and
3,245 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,7 +1,8 @@ | ||
node_modules/ | ||
*.tsbuildinfo | ||
*.log | ||
/dist/ | ||
/pkg/*/graphql.go | ||
/pkg/*/schema.graphql | ||
!/pkg/graphql/schema.graphql | ||
/packages/*/dist/ | ||
/examples/*/graphql.go | ||
/examples/*/schema.graphql | ||
!/examples/graphql/schema.graphql | ||
.turbo/ |
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,2 @@ | ||
//registry.npmjs.org/:_authToken=$NPM_TOKEN | ||
auto-install-peers=true |
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,2 +1,2 @@ | ||
/dist/ | ||
dist/ | ||
pnpm-lock.yaml |
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
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 @@ | ||
./packages/graphql-codegen-golang/README.md |
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 @@ | ||
module examples | ||
|
||
go 1.18 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
go 1.18 | ||
|
||
use ./pkg/rickandmorty | ||
use ./examples/ |
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,24 +1,25 @@ | ||
projects: | ||
default: | ||
schema: pkg/graphql/schema.graphql | ||
documents: pkg/graphql/!(schema).graphql | ||
schema: examples/graphql/schema.graphql | ||
documents: examples/graphql/!(schema).graphql | ||
extensions: | ||
codegen: | ||
generates: | ||
pkg/graphql/graphql.go: | ||
examples/graphql/graphql.go: | ||
hooks: | ||
afterOneFileWrite: go fmt | ||
plugins: | ||
- dist/index.js | ||
- packages/graphql-codegen-golang/dist/index.js | ||
rickandmorty: | ||
schema: https://rickandmortyapi.com/graphql/ | ||
documents: pkg/rickandmorty/document.graphql | ||
documents: examples/rickandmorty/document.graphql | ||
extensions: | ||
codegen: | ||
generates: | ||
pkg/rickandmorty/graphql.go: | ||
examples/rickandmorty/graphql.go: | ||
hooks: | ||
afterOneFileWrite: go fmt | ||
plugins: | ||
- dist/index.js: | ||
- packages/graphql-codegen-golang/dist/index.js: | ||
packageName: rickandmorty | ||
generateHTTPClient: true |
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# GraphQL Code Generator plugin for generating Golang | ||
|
||
## Roadmap | ||
|
||
- [x] Generate types | ||
- [x] Generate queries and mutations | ||
- [ ] Generate subscriptions with gorilla websocket | ||
- [ ] Generate Terraform providers | ||
- [ ] Generate CLI | ||
- [ ] Add more configuration options | ||
- [ ] Avoid possible naming collisions | ||
|
||
This package generates Golang types from GraphQL schema, and can optionally generate: | ||
|
||
- An HTTP client | ||
- A Terraform provider wrapping the generated HTTP client (TODO) | ||
- A cobra CLI wrapping the generated HTTP client (TODO) | ||
|
||
## Install | ||
|
||
The package is published to [graphql-codegen-golang](https://www.npmjs.com/package/graphql-codegen-golang). | ||
|
||
```sh | ||
pnpm add -DE graphql-codegen-golang | ||
yarn add -DE graphql-codegen-golang | ||
npm install -DE graphql-codegen-golang | ||
``` | ||
|
||
## Usage: `codegen.yaml` | ||
|
||
```yaml | ||
schema: examples/graphql/schema.graphql | ||
documents: examples/graphql/!(schema).graphql | ||
generates: | ||
examples/graphql/graphql.go: | ||
hooks: | ||
afterOneFileWrite: go fmt | ||
plugins: | ||
- graphql-codegen-golang: | ||
packageName: graphql # default | ||
generateHTTPClient: false # default | ||
``` | ||
## Configuration | ||
Configuration source is at [src/config.ts](src/config.ts) | ||
| Name | Type | Default | Description | | ||
| ------------------ | ------- | ------- | ------------------------------------------ | | ||
| packageName | string | graphql | Name of the generated Golang package. | | ||
| generateHTTPClient | boolean | false | Should an GraphQL HTTP client be generated | |
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,32 @@ | ||
{ | ||
"name": "graphql-codegen-golang", | ||
"description": "Graphql Code Generator plugin for generating Golang", | ||
"keywords": [ | ||
"graphql-codegen", | ||
"graphql", | ||
"golang" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/ctison/graphql-codegen-golang.git" | ||
}, | ||
"license": "MIT", | ||
"files": [ | ||
"README.md", | ||
"dist/" | ||
], | ||
"dependencies": { | ||
"@graphql-codegen/plugin-helpers": "2.7.0", | ||
"graphql": "16.6.0", | ||
"liquidjs": "9.42.0" | ||
}, | ||
"devDependencies": { | ||
"typescript": "4.8.2" | ||
}, | ||
"scripts": { | ||
"build": "rm -rf dist/ && tsc -p tsconfig.build.json", | ||
"dev": "rm -rf dist/ && tsc -p tsconfig.build.json -w" | ||
}, | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts" | ||
} |
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
Oops, something went wrong.