Skip to content

Commit

Permalink
fix: link for bundle size reduction docs (#10075)
Browse files Browse the repository at this point in the history
  • Loading branch information
n1ru4l authored Jul 30, 2024
1 parent 942c25d commit 67e7556
Show file tree
Hide file tree
Showing 25 changed files with 41 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/pretty-berries-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@graphql-codegen/gql-tag-operations': patch
'@graphql-codegen/client-preset': patch
---

Add note about enabling bundle size reduction for the generated `graphql` tag file.
1 change: 1 addition & 0 deletions dev-test/gql-tag-operations-masking/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n fragment TweetFragment on Tweet {\n id\n body\n ...TweetAuthorFragment\n }\n':
Expand Down
1 change: 1 addition & 0 deletions dev-test/gql-tag-operations-urql/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n query Foo {\n Tweets {\n id\n }\n }\n': types.FooDocument,
Expand Down
1 change: 1 addition & 0 deletions dev-test/gql-tag-operations/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n query Foo {\n Tweets {\n id\n }\n }\n': types.FooDocument,
Expand Down
1 change: 1 addition & 0 deletions dev-test/gql-tag-operations/graphql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n query Foo {\n Tweets {\n id\n }\n }\n': types.FooDocument,
Expand Down
1 change: 1 addition & 0 deletions examples/persisted-documents-string-mode/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as types from './graphql';
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n query HelloQuery {\n hello\n }\n': types.HelloQueryDocument,
Expand Down
1 change: 1 addition & 0 deletions examples/persisted-documents/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n query HelloQuery {\n hello\n }\n': types.HelloQueryDocument,
Expand Down
1 change: 1 addition & 0 deletions examples/react/apollo-client-defer/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n fragment SlowFieldFragment on Query {\n slowField(waitFor: 5000)\n }\n': types.SlowFieldFragmentFragmentDoc,
Expand Down
1 change: 1 addition & 0 deletions examples/react/apollo-client-swc-plugin/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n query allFilmsWithVariablesQuery($first: Int!) {\n allFilms(first: $first) {\n edges {\n node {\n ...FilmItem\n }\n }\n }\n }\n':
Expand Down
1 change: 1 addition & 0 deletions examples/react/apollo-client/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n query allFilmsWithVariablesQuery($first: Int!) {\n allFilms(first: $first) {\n edges {\n node {\n ...FilmItem\n }\n }\n }\n }\n':
Expand Down
1 change: 1 addition & 0 deletions examples/react/http-executor/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n query allFilmsWithVariablesQuery($first: Int!) {\n allFilms(first: $first) {\n edges {\n node {\n ...FilmItem\n }\n }\n }\n }\n':
Expand Down
1 change: 1 addition & 0 deletions examples/react/nextjs-swr/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n fragment FilmItem on Film {\n id\n title\n releaseDate\n producers\n }\n':
Expand Down
1 change: 1 addition & 0 deletions examples/react/tanstack-react-query/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as types from './graphql';
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n query allFilmsWithVariablesQuery($first: Int!) {\n allFilms(first: $first) {\n edges {\n node {\n ...FilmItem\n }\n }\n }\n }\n':
Expand Down
1 change: 1 addition & 0 deletions examples/react/urql/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as types from './graphql';
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n query allFilmsWithVariablesQuery199($first: Int!) {\n allFilms(first: $first) {\n edges {\n node {\n ...FilmItem\n }\n }\n }\n }\n':
Expand Down
1 change: 1 addition & 0 deletions examples/typescript-esm/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n query AllPeopleQuery {\n allPeople(first: 5) {\n edges {\n node {\n name\n homeworld {\n name\n }\n }\n }\n }\n }\n':
Expand Down
1 change: 1 addition & 0 deletions examples/typescript-graphql-request/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as types from './graphql';
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n query AllPeopleQuery {\n allPeople(first: 5) {\n edges {\n node {\n name\n homeworld {\n name\n }\n }\n }\n }\n }\n':
Expand Down
1 change: 1 addition & 0 deletions examples/vite/vite-react-cts/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n fragment FilmItem on Film {\n id\n title\n releaseDate\n producers\n }\n':
Expand Down
1 change: 1 addition & 0 deletions examples/vite/vite-react-mts/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n fragment FilmItem on Film {\n id\n title\n releaseDate\n producers\n }\n':
Expand Down
1 change: 1 addition & 0 deletions examples/vite/vite-react-ts/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n fragment FilmItem on Film {\n id\n title\n releaseDate\n producers\n }\n':
Expand Down
1 change: 1 addition & 0 deletions examples/vue/apollo-composable/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n query allFilmsWithVariablesQuery($first: Int!) {\n allFilms(first: $first) {\n edges {\n node {\n ...FilmItem\n }\n }\n }\n }\n ':
Expand Down
1 change: 1 addition & 0 deletions examples/vue/urql/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n query allFilmsWithVariablesQuery($first: Int!) {\n allFilms(first: $first) {\n edges {\n node {\n ...FilmItem\n }\n }\n }\n }\n ':
Expand Down
1 change: 1 addition & 0 deletions examples/vue/villus/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n query allFilmsWithVariablesQuery($first: Int!) {\n allFilms(first: $first) {\n edges {\n node {\n ...FilmItem\n }\n }\n }\n }\n ':
Expand Down
1 change: 1 addition & 0 deletions examples/yoga-tests/src/gql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
'\n query HelloQuery {\n hello\n }\n ': types.HelloQueryDocument,
Expand Down
5 changes: 4 additions & 1 deletion packages/plugins/typescript/gql-tag-operations/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ function getDocumentRegistryChunk(sourcesWithOperations: Array<SourceWithOperati
lines.add(` * 1. It is not tree-shakeable, so it will include all operations in the project.\n`);
lines.add(` * 2. It is not minifiable, so the string of a GraphQL query will be multiple times inside the bundle.\n`);
lines.add(` * 3. It does not support dead code elimination, so it will add unused operations.\n *\n`);
lines.add(` * Therefore it is highly recommended to use the babel or swc plugin for production.\n */\n`);
lines.add(` * Therefore it is highly recommended to use the babel or swc plugin for production.\n`);
lines.add(
` * Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size\n */\n`
);
lines.add(`const documents = {\n`);

for (const { operations, ...rest } of sourcesWithOperations) {
Expand Down
9 changes: 9 additions & 0 deletions packages/presets/client/tests/client-preset.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export * from "./gql";`);
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
"\\n query A {\\n a\\n }\\n": types.ADocument,
Expand Down Expand Up @@ -136,6 +137,7 @@ export * from "./gql";`);
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
"\\n query a {\\n a\\n }\\n": types.ADocument,
Expand Down Expand Up @@ -215,6 +217,7 @@ export * from "./gql";`);
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
"\\n query a {\\n a\\n }\\n": types.ADocument,
Expand Down Expand Up @@ -295,6 +298,7 @@ export * from "./gql";`);
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
"\\n query A {\\n a\\n }\\n": types.ADocument,
Expand Down Expand Up @@ -425,6 +429,7 @@ export * from "./gql";`);
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
"\\n query A {\\n a\\n }\\n": types.ADocument,
Expand Down Expand Up @@ -548,6 +553,7 @@ export * from "./gql";`);
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
"\\n query a {\\n a\\n }\\n": types.ADocument,
Expand Down Expand Up @@ -661,6 +667,7 @@ export * from "./gql";`);
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
"\\n query A {\\n a\\n }\\n": types.ADocument,
Expand Down Expand Up @@ -1008,6 +1015,7 @@ export * from "./gql.js";`);
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
"\\n query A {\\n a\\n }\\n": types.ADocument,
Expand Down Expand Up @@ -2682,6 +2690,7 @@ export * from "./gql.js";`);
* 3. It does not support dead code elimination, so it will add unused operations.
*
* Therefore it is highly recommended to use the babel or swc plugin for production.
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
"\\n query Foo {\\n foo {\\n ...Foo\\n }\\n }\\n": types.FooDocument,
Expand Down

0 comments on commit 67e7556

Please sign in to comment.