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 #1229 from Quramy/add_gql_codegen_example
docs: Add example using graphql-codegen
- Loading branch information
Showing
16 changed files
with
5,915 additions
and
14 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
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,8 +1,15 @@ | ||
const assert = require('assert'); | ||
|
||
async function run(cli) { | ||
const { code } = await cli.run('validate', ['-p', 'project-fixtures/gql-errors-prj', '--verbose']); | ||
assert.equal(code, 1); | ||
for (const fixtureDir of ['project-fixtures/gql-errors-prj']) { | ||
const { code } = await cli.run('validate', ['-p', fixtureDir, '--verbose']); | ||
assert.equal(code, 1); | ||
} | ||
|
||
for (const fixtureDir of ['project-fixtures/react-apollo-prj', 'project-fixtures/graphql-codegen-prj']) { | ||
const { code } = await cli.run('validate', ['-p', fixtureDir, '--verbose']); | ||
assert.equal(code, 0); | ||
} | ||
} | ||
|
||
module.exports = run; |
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 @@ | ||
{ | ||
"typescript.tsdk": "node_modules/typescript/lib", | ||
"typescript.enablePromptUseWorkspaceTsdk": true | ||
} |
40 changes: 40 additions & 0 deletions
40
project-fixtures/graphql-codegen-prj/GRAPHQL_OPERATIONS.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,40 @@ | ||
# Extracted GraphQL Operations | ||
## Queries | ||
|
||
### AppQuery | ||
|
||
```graphql | ||
query AppQuery { | ||
popularPosts { | ||
id | ||
...Post_Post | ||
} | ||
} | ||
|
||
fragment Post_Post on Post { | ||
title | ||
author { | ||
name | ||
} | ||
} | ||
``` | ||
|
||
From [src/App.tsx:24:24](src/App.tsx#L24-L31) | ||
|
||
## Fragments | ||
|
||
### Post_Post | ||
|
||
```graphql | ||
fragment Post_Post on Post { | ||
title | ||
author { | ||
name | ||
} | ||
} | ||
``` | ||
|
||
From [src/App.tsx:5:31](src/App.tsx#L5-L12) | ||
|
||
--- | ||
Extracted by [ts-graphql-plugin](https://github.com/Quramy/ts-graphql-plugin) |
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,13 @@ | ||
# graphql-codege example | ||
|
||
## How to run this example | ||
|
||
- (At the root of ts-graphql-plugin project directory) | ||
- Execute `npm link` command. | ||
|
||
```sh | ||
$ cd project-fixtures/graphql-codegen-prj | ||
$ npm install | ||
$ npm link ts-graphql-plugin | ||
$ code . | ||
``` |
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,14 @@ | ||
import type { CodegenConfig } from '@graphql-codegen/cli'; | ||
|
||
const config: CodegenConfig = { | ||
overwrite: true, | ||
schema: 'schema.graphql', | ||
documents: ['src/**/*.tsx'], | ||
generates: { | ||
'src/gql/': { | ||
preset: 'client', | ||
}, | ||
}, | ||
}; | ||
|
||
export default config; |
Oops, something went wrong.