Skip to content

Commit 365b272

Browse files
author
Minh Cung
authored
Merge branch 'master' into patch-1
2 parents e7af08b + 22e723a commit 365b272

File tree

246 files changed

+7149
-3656
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+7149
-3656
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@graphql-codegen/client-preset": patch
3+
---
4+
dependencies updates:
5+
- Added dependency [`@graphql-tools/documents@^0.1.0` ↗︎](https://www.npmjs.com/package/@graphql-tools/documents/v/0.1.0) (to `dependencies`)

.changeset/big-mice-switch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/cli': patch
3+
---
4+
5+
fix: `gqlMagicComment` type

.changeset/lemon-zebras-hunt.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
'@graphql-codegen/client-preset': minor
3+
---
4+
5+
Add support for persisted documents.
6+
7+
You can now generate and embed a persisted documents hash for the executable documents.
8+
9+
```ts
10+
/** codegen.ts */
11+
import { CodegenConfig } from '@graphql-codegen/cli'
12+
13+
const config: CodegenConfig = {
14+
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
15+
documents: ['src/**/*.tsx'],
16+
ignoreNoDocuments: true, // for better experience with the watcher
17+
generates: {
18+
'./src/gql/': {
19+
preset: 'client',
20+
plugins: [],
21+
presetConfig: {
22+
persistedOperations: true,
23+
}
24+
}
25+
}
26+
}
27+
28+
export default config
29+
```
30+
31+
This will generate `./src/gql/persisted-documents.json` (dictionary of hashes with their operation string).
32+
33+
In addition to that each generated document node will have a `__meta__.hash` property.
34+
35+
```ts
36+
import { gql } from './gql.js'
37+
38+
const allFilmsWithVariablesQueryDocument = graphql(/* GraphQL */ `
39+
query allFilmsWithVariablesQuery($first: Int!) {
40+
allFilms(first: $first) {
41+
edges {
42+
node {
43+
...FilmItem
44+
}
45+
}
46+
}
47+
}
48+
`)
49+
50+
console.log((allFilmsWithVariablesQueryDocument as any)["__meta__"]["hash"])
51+
```
52+

.changeset/tasty-adults-doubt.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
'@graphql-codegen/client-preset': minor
3+
---
4+
5+
Add support for embedding metadata in the document AST.
6+
7+
It is now possible to embed metadata (e.g. for your GraphQL client within the emitted code).
8+
9+
```ts
10+
/** codegen.ts */
11+
import { CodegenConfig } from '@graphql-codegen/cli'
12+
13+
const config: CodegenConfig = {
14+
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
15+
documents: ['src/**/*.tsx'],
16+
ignoreNoDocuments: true, // for better experience with the watcher
17+
generates: {
18+
'./src/gql/': {
19+
preset: 'client',
20+
plugins: [],
21+
presetConfig: {
22+
onExecutableDocumentNode(documentNode) {
23+
return {
24+
operation: documentNode.definitions[0].operation,
25+
name: documentNode.definitions[0].name.value
26+
}
27+
}
28+
}
29+
}
30+
}
31+
}
32+
33+
export default config
34+
```
35+
36+
You can then access the metadata via the `__meta__` property on the document node.
37+
38+
```ts
39+
import { gql } from './gql.js'
40+
41+
const allFilmsWithVariablesQueryDocument = graphql(/* GraphQL */ `
42+
query allFilmsWithVariablesQuery($first: Int!) {
43+
allFilms(first: $first) {
44+
edges {
45+
node {
46+
...FilmItem
47+
}
48+
}
49+
}
50+
}
51+
`)
52+
53+
console.log((allFilmsWithVariablesQueryDocument as any)["__meta__"])
54+
```

.changeset/unlucky-suits-pay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/visitor-plugin-common': patch
3+
---
4+
5+
Fix issue where visitor-plugin-common emitted ESM imports for Operations when emitLegacyCommonJSImports is true

.eslintrc.cjs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
module.exports = {
2+
root: true,
3+
extends: ['@theguild'],
4+
rules: {
5+
'no-empty': 'off',
6+
'@typescript-eslint/explicit-module-boundary-types': 'off',
7+
'@typescript-eslint/no-use-before-define': 'off',
8+
'@typescript-eslint/no-namespace': 'off',
9+
'@typescript-eslint/no-empty-interface': 'off',
10+
'@typescript-eslint/no-empty-function': 'off',
11+
'@typescript-eslint/no-var-requires': 'off',
12+
'@typescript-eslint/no-explicit-any': 'off',
13+
'@typescript-eslint/no-non-null-assertion': 'off',
14+
'@typescript-eslint/explicit-function-return-type': 'off',
15+
'@typescript-eslint/ban-ts-ignore': 'off',
16+
'@typescript-eslint/ban-types': 'off',
17+
'import/no-extraneous-dependencies': [
18+
'error',
19+
{ devDependencies: ['**/*.test.ts', '**/*.spec.ts', '**/test/**/*.ts'] },
20+
],
21+
22+
// todo: enable
23+
'unicorn/filename-case': 'off',
24+
'import/extensions': 'off',
25+
'import/no-default-export': 'off',
26+
// todo: enable in v3
27+
'unicorn/prefer-node-protocol': 'off',
28+
'prefer-object-has-own': 'off',
29+
},
30+
env: {
31+
node: true,
32+
},
33+
overrides: [
34+
{
35+
files: ['website/**'],
36+
extends: '@theguild/eslint-config/react',
37+
},
38+
{
39+
files: ['**/tests/**/*.{js,ts,tsx}', '**/graphql-codegen-testing/**/*.ts', '*.spec.ts'],
40+
env: {
41+
jest: true,
42+
},
43+
rules: {
44+
'import/no-extraneous-dependencies': 'off',
45+
},
46+
},
47+
{
48+
files: '**/tests/fixtures/*.ts',
49+
rules: {
50+
'@typescript-eslint/no-unused-vars': 'off',
51+
},
52+
},
53+
],
54+
ignorePatterns: ['dev-test', 'examples/front-end', 'website'],
55+
};

.eslintrc.json

Lines changed: 0 additions & 53 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/feature_request.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,21 +50,21 @@ body:
5050
validations:
5151
required: true
5252
- type: textarea
53-
id: description
53+
id: solution
5454
attributes:
5555
label: Describe the solution you'd like
5656
description: 'A clear and concise description of what you want to happen.'
5757
validations:
5858
required: true
5959
- type: textarea
60-
id: description
60+
id: alternatives
6161
attributes:
6262
label: Describe alternatives you've considered
6363
description: "A clear and concise description of any alternative solutions or features you've considered."
6464
validations:
6565
required: false
6666
- type: textarea
67-
id: description
67+
id: context
6868
attributes:
6969
label: Is your feature request related to a problem? Please describe.
7070
description: 'Add any other context or screenshots about the feature request here.'

.gitignore

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55
coverage
66
*.log
77
node_modules/
8-
temp
8+
temp/
99
junit.xml
1010
dist/
1111
.bob/
1212
out.txt
1313
.cache
1414
tsconfig.tsbuildinfo
15-
.yarn
15+
.yarn/
1616
recompile.sh
1717

1818
.next/
19-
out
19+
out/
2020
website/public/sitemap.xml
2121
website/public/_redirects
22+
.eslintcache

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16
1+
18

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ website/src/pages/plugins/presets/near-operation-file-preset.mdx
2222
examples/**/gql/**
2323

2424
website/algolia-lockfile.json
25+
temp/

README.md

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,59 @@
1-
[![CodeGen](./logo.svg)](https://graphql-code-generator.com)
1+
[![CodeGen](./logo.svg)](https://the-guild.dev/graphql/codegen)
22

33
[![npm version](https://badge.fury.io/js/%40graphql-codegen%2Fcli.svg)](https://badge.fury.io/js/%40graphql-codegen%2Fcli)
44

5-
[graphql-code-generator.com](https://graphql-code-generator.com)
5+
[https://the-guild.dev/graphql/codegen](https://the-guild.dev/graphql/codegen)
66

77
GraphQL Code Generator is a tool that generates code out of your GraphQL schema. Whether you are developing a frontend or backend, you can utilize GraphQL Code Generator to generate output from your GraphQL Schema and GraphQL Documents (query/mutation/subscription/fragment).
88

99
By analyzing the schema and documents and parsing it, GraphQL Code Generator can output code at a wide variety of formats, based on pre-defined templates or based on custom user-defined ones. Regardless of the language that you're using, GraphQL Code Generator got you covered.
1010

1111
GraphQL Code Generator lets you choose the output that you need, based on _plugins_, which are very flexible and customizable. You can also write your _plugins_ to generate custom outputs that match your needs.
1212

13-
You can try this tool live on your browser and see some useful examples. Check out [GraphQL Code Generator Live Examples](https://graphql-code-generator.com/#live-demo).
13+
You can try this tool live on your browser and see some useful examples. Check out [GraphQL Code Generator Live Examples](https://the-guild.dev/graphql/codegen/#live-demo).
1414

15-
We currently support and maintain [these plugins](https://graphql-code-generator.com/plugins) (TypeScript, Flow, React, Angular, MongoDB, Stencil, Reason, and some more), and there is an active community that writes and maintains custom plugins.
15+
We currently support and maintain [these plugins](https://the-guild.dev/graphql/codegen/plugins) (TypeScript, Flow, React, Angular, MongoDB, Stencil, Reason, and some more), and there is an active community that writes and maintains custom plugins.
1616

17-
### Quick Start
17+
## Quick Start
1818

19-
> You can find the complete instructions in [GraphQL-Code-Generator website](https://graphql-code-generator.com/docs/getting-started/installation).
19+
> You can find the complete instructions in [GraphQL Code Generator website](https://the-guild.dev/graphql/codegen/docs/getting-started/installation).
2020
2121
Start by installing the basic deps of GraphQL Codegen;
2222

23-
yarn add graphql
24-
yarn add -D @graphql-codegen/cli
23+
```bash
24+
yarn add graphql
25+
yarn add -D @graphql-codegen/cli
26+
```
2527

2628
GraphQL Code Generator lets you setup everything by simply running the following command:
2729

28-
yarn graphql-codegen init
30+
```bash
31+
yarn graphql-codegen init
32+
```
2933

3034
Question by question, it will guide you through the whole process of setting up a schema, selecting plugins, picking a destination of a generated file, and a lot more.
3135

32-
If you wish to [manually setup codegen, follow these instructions](https://graphql-code-generator.com/docs/getting-started/installation).
36+
If you wish to [manually setup codegen, follow these instructions](https://the-guild.dev/graphql/codegen/docs/getting-started/installation).
3337

34-
### Links
38+
## Links
3539

36-
Besides our [docs page](https://graphql-code-generator.com/docs/getting-started), feel free to go through our published Medium articles to get a better grasp of what GraphQL Code Generator is all about:
40+
Besides our [docs page](https://the-guild.dev/graphql/codegen/docs/getting-started), feel free to go through our published Medium articles to get a better grasp of what GraphQL Code Generator is all about:
3741

38-
- [All available plugins & presets](https://graphql-code-generator.com/plugins)
42+
- [All available plugins & presets](https://the-guild.dev/graphql/codegen/plugins)
3943

40-
### Contributing
44+
## Contributing
4145

4246
If this is your first time contributing to this project, please do read our [Contributor Workflow Guide](https://github.com/the-guild-org/Stack/blob/master/CONTRIBUTING.md) before you get started off.
4347

4448
Feel free to open issues and pull requests. We're always welcome support from the community.
4549

46-
For a contribution guide specific to this project, please refer to: http://graphql-code-generator.com/docs/custom-codegen/contributing
50+
For a contribution guide specific to this project, please refer to: http://the-guild.dev/graphql/codegen/docs/custom-codegen/contributing
4751

48-
### Code of Conduct
52+
## Code of Conduct
4953

50-
Help us keep GraphQL Codegenerator open and inclusive. Please read and follow our [Code of Conduct](https://github.com/the-guild-org/Stack/blob/master/CODE_OF_CONDUCT.md) as adopted from [Contributor Covenant](https://www.contributor-covenant.org/)
54+
Help us keep GraphQL Code Generator open and inclusive. Please read and follow our [Code of Conduct](https://github.com/the-guild-org/Stack/blob/master/CODE_OF_CONDUCT.md) as adopted from [Contributor Covenant](https://contributor-covenant.org)
5155

52-
### License
56+
## License
5357

5458
[![GitHub license](https://img.shields.io/badge/license-MIT-lightgrey.svg?maxAge=2592000)](https://raw.githubusercontent.com/apollostack/apollo-ios/master/LICENSE)
5559

0 commit comments

Comments
 (0)