A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.
MIT License
Bot releases are hidden (Show)
Published by n1ru4l over 1 year ago
#8893 a118c307a
Thanks @n1ru4l! - It is no longer mandatory to declare an empty plugins array when using a preset
#8723 a3309e63e
Thanks @kazekyo! - Introduce a new feature called DocumentTransform.
DocumentTransform is a functionality that allows you to modify documents
before they are processed by plugins. You can use functions passed to the documentTransforms
option to make changes to GraphQL documents.
To use this feature, you can write documentTransforms
as follows:
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: [
{
transform: ({ documents }) => {
// Make some changes to the documents
return documents;
},
},
],
},
},
};
export default config;
For instance, to remove a @localOnlyDirective
directive from documents
, you can write the following code:
import type { CodegenConfig } from '@graphql-codegen/cli';
import { visit } from 'graphql';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: [
{
transform: ({ documents }) => {
return documents.map(documentFile => {
documentFile.document = visit(documentFile.document, {
Directive: {
leave(node) {
if (node.name.value === 'localOnlyDirective') return null;
},
},
});
return documentFile;
});
},
},
],
},
},
};
export default config;
DocumentTransform can also be specified by file name. You can create a custom file for a specific transformation and pass it to documentTransforms
.
Let's create the document transform as a file:
module.exports = {
transform: ({ documents }) => {
// Make some changes to the documents
return documents;
},
};
Then, you can specify the file name as follows:
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: ['./my-document-transform.js'],
},
},
};
export default config;
4c422ccf6
Thanks @renovate! - dependencies updates:
@whatwg-node/fetch@^0.8.0
↗︎ (from ^0.6.0
, in dependencies
)8206b268d
, 8206b268d
, a118c307a
, a3309e63e
]:
#8723 a3309e63e
Thanks @kazekyo! - Introduce a new feature called DocumentTransform.
DocumentTransform is a functionality that allows you to modify documents
before they are processed by plugins. You can use functions passed to the documentTransforms
option to make changes to GraphQL documents.
To use this feature, you can write documentTransforms
as follows:
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: [
{
transform: ({ documents }) => {
// Make some changes to the documents
return documents;
},
},
],
},
},
};
export default config;
For instance, to remove a @localOnlyDirective
directive from documents
, you can write the following code:
import type { CodegenConfig } from '@graphql-codegen/cli';
import { visit } from 'graphql';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: [
{
transform: ({ documents }) => {
return documents.map(documentFile => {
documentFile.document = visit(documentFile.document, {
Directive: {
leave(node) {
if (node.name.value === 'localOnlyDirective') return null;
},
},
});
return documentFile;
});
},
},
],
},
},
};
export default config;
DocumentTransform can also be specified by file name. You can create a custom file for a specific transformation and pass it to documentTransforms
.
Let's create the document transform as a file:
module.exports = {
transform: ({ documents }) => {
// Make some changes to the documents
return documents;
},
};
Then, you can specify the file name as follows:
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: ['./my-document-transform.js'],
},
},
};
export default config;
8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)8206b268d
, a118c307a
, a3309e63e
]:
b13aa7449
Thanks @KGAdamCook! - Updated customResolveInfo to use the correct importType for external imports8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)8206b268d
, 8206b268d
, 8206b268d
, a118c307a
, 6b6fe3cbc
, a3309e63e
]:
#8893 a118c307a
Thanks @n1ru4l! - It is no longer mandatory to declare an empty plugins array when using a preset
#8723 a3309e63e
Thanks @kazekyo! - Introduce a new feature called DocumentTransform.
DocumentTransform is a functionality that allows you to modify documents
before they are processed by plugins. You can use functions passed to the documentTransforms
option to make changes to GraphQL documents.
To use this feature, you can write documentTransforms
as follows:
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: [
{
transform: ({ documents }) => {
// Make some changes to the documents
return documents;
},
},
],
},
},
};
export default config;
For instance, to remove a @localOnlyDirective
directive from documents
, you can write the following code:
import type { CodegenConfig } from '@graphql-codegen/cli';
import { visit } from 'graphql';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: [
{
transform: ({ documents }) => {
return documents.map(documentFile => {
documentFile.document = visit(documentFile.document, {
Directive: {
leave(node) {
if (node.name.value === 'localOnlyDirective') return null;
},
},
});
return documentFile;
});
},
},
],
},
},
};
export default config;
DocumentTransform can also be specified by file name. You can create a custom file for a specific transformation and pass it to documentTransforms
.
Let's create the document transform as a file:
module.exports = {
transform: ({ documents }) => {
// Make some changes to the documents
return documents;
},
};
Then, you can specify the file name as follows:
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: ['./my-document-transform.js'],
},
},
};
export default config;
#8879 8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)#8995 fe2e9c7a5
Thanks @charpeni! - Use gqlTagName
for generated examples
#8971 6b6fe3cbc
Thanks @n1ru4l! - Allow passing fragment documents to APIs like Apollos readFragment
Updated dependencies [8206b268d
, 8206b268d
, 8206b268d
, 8206b268d
, 8206b268d
, 8206b268d
, 8206b268d
, a118c307a
, fe2e9c7a5
, 6b6fe3cbc
, 6b6fe3cbc
, a3309e63e
]:
#8893 a118c307a
Thanks @n1ru4l! - It is no longer mandatory to declare an empty plugins array when using a preset
#8723 a3309e63e
Thanks @kazekyo! - Introduce a new feature called DocumentTransform.
DocumentTransform is a functionality that allows you to modify documents
before they are processed by plugins. You can use functions passed to the documentTransforms
option to make changes to GraphQL documents.
To use this feature, you can write documentTransforms
as follows:
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: [
{
transform: ({ documents }) => {
// Make some changes to the documents
return documents;
},
},
],
},
},
};
export default config;
For instance, to remove a @localOnlyDirective
directive from documents
, you can write the following code:
import type { CodegenConfig } from '@graphql-codegen/cli';
import { visit } from 'graphql';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: [
{
transform: ({ documents }) => {
return documents.map(documentFile => {
documentFile.document = visit(documentFile.document, {
Directive: {
leave(node) {
if (node.name.value === 'localOnlyDirective') return null;
},
},
});
return documentFile;
});
},
},
],
},
},
};
export default config;
DocumentTransform can also be specified by file name. You can create a custom file for a specific transformation and pass it to documentTransforms
.
Let's create the document transform as a file:
module.exports = {
transform: ({ documents }) => {
// Make some changes to the documents
return documents;
},
};
Then, you can specify the file name as follows:
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: ['./my-document-transform.js'],
},
},
};
export default config;
8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)8206b268d
, 8206b268d
, 8206b268d
, 8206b268d
, 8206b268d
, 8206b268d
, 8206b268d
, a118c307a
, fe2e9c7a5
, 6b6fe3cbc
, 6b6fe3cbc
, a3309e63e
]:
#8723 a3309e63e
Thanks @kazekyo! - Introduce a new feature called DocumentTransform.
DocumentTransform is a functionality that allows you to modify documents
before they are processed by plugins. You can use functions passed to the documentTransforms
option to make changes to GraphQL documents.
To use this feature, you can write documentTransforms
as follows:
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: [
{
transform: ({ documents }) => {
// Make some changes to the documents
return documents;
},
},
],
},
},
};
export default config;
For instance, to remove a @localOnlyDirective
directive from documents
, you can write the following code:
import type { CodegenConfig } from '@graphql-codegen/cli';
import { visit } from 'graphql';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: [
{
transform: ({ documents }) => {
return documents.map(documentFile => {
documentFile.document = visit(documentFile.document, {
Directive: {
leave(node) {
if (node.name.value === 'localOnlyDirective') return null;
},
},
});
return documentFile;
});
},
},
],
},
},
};
export default config;
DocumentTransform can also be specified by file name. You can create a custom file for a specific transformation and pass it to documentTransforms
.
Let's create the document transform as a file:
module.exports = {
transform: ({ documents }) => {
// Make some changes to the documents
return documents;
},
};
Then, you can specify the file name as follows:
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: ['./my-document-transform.js'],
},
},
};
export default config;
8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)8206b268d
, 8206b268d
, a118c307a
, 6b6fe3cbc
, a3309e63e
]:
#8893 a118c307a
Thanks @n1ru4l! - mark plugins
in config optional
#8723 a3309e63e
Thanks @kazekyo! - Introduce a new feature called DocumentTransform.
DocumentTransform is a functionality that allows you to modify documents
before they are processed by plugins. You can use functions passed to the documentTransforms
option to make changes to GraphQL documents.
To use this feature, you can write documentTransforms
as follows:
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: [
{
transform: ({ documents }) => {
// Make some changes to the documents
return documents;
},
},
],
},
},
};
export default config;
For instance, to remove a @localOnlyDirective
directive from documents
, you can write the following code:
import type { CodegenConfig } from '@graphql-codegen/cli';
import { visit } from 'graphql';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: [
{
transform: ({ documents }) => {
return documents.map(documentFile => {
documentFile.document = visit(documentFile.document, {
Directive: {
leave(node) {
if (node.name.value === 'localOnlyDirective') return null;
},
},
});
return documentFile;
});
},
},
],
},
},
};
export default config;
DocumentTransform can also be specified by file name. You can create a custom file for a specific transformation and pass it to documentTransforms
.
Let's create the document transform as a file:
module.exports = {
transform: ({ documents }) => {
// Make some changes to the documents
return documents;
},
};
Then, you can specify the file name as follows:
import type { CodegenConfig } from '@graphql-codegen/cli';
const config: CodegenConfig = {
schema: 'https://localhost:4000/graphql',
documents: ['src/**/*.tsx'],
generates: {
'./src/gql/': {
preset: 'client',
documentTransforms: ['./my-document-transform.js'],
},
},
};
export default config;
8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)4c422ccf6
, a118c307a
, a3309e63e
]:
8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)8206b268d
, a118c307a
, a3309e63e
]:
8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)8206b268d
, a118c307a
, a3309e63e
]:
8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)8206b268d
, 8206b268d
, a118c307a
, 6b6fe3cbc
, a3309e63e
]:
8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)8206b268d
, a118c307a
, a3309e63e
]:
#8879 8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)#8971 6b6fe3cbc
Thanks @n1ru4l! - Always inline referenced fragments within their document. This prevents issues with duplicated fragments or missing fragments.
Updated dependencies [8206b268d
, a118c307a
, a3309e63e
]:
8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)8206b268d
, 8206b268d
, a118c307a
, 6b6fe3cbc
, a3309e63e
]:
#8879 8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)#8995 fe2e9c7a5
Thanks @charpeni! - Use gqlTagName
for generated examples
Updated dependencies [8206b268d
, 8206b268d
, a118c307a
, 6b6fe3cbc
, a3309e63e
]:
8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)8206b268d
, 8206b268d
, 8206b268d
, a118c307a
, 6b6fe3cbc
, a3309e63e
]:
#8879 8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)#8971 6b6fe3cbc
Thanks @n1ru4l! - Allow passing fragment documents to APIs like Apollos readFragment
Updated dependencies [8206b268d
, 8206b268d
, a118c307a
, 6b6fe3cbc
, a3309e63e
]:
8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)8206b268d
, 8206b268d
, 8206b268d
, a118c307a
, 6b6fe3cbc
, a3309e63e
]:
8206b268d
Thanks @renovate! - dependencies updates:
tslib@~2.5.0
↗︎ (from ~2.4.0
, in dependencies
)8206b268d
, a118c307a
, a3309e63e
]: