Skip to content

Commit 73c5cfc

Browse files
authored
docs: improvements (#10072)
* docs: improvements * apply feedback from review
1 parent 67e7556 commit 73c5cfc

File tree

5 files changed

+86
-86
lines changed

5 files changed

+86
-86
lines changed

website/src/components/index-page.tsx

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
import { ReactElement } from 'react';
2-
import dynamic from 'next/dynamic';
32
import { HeroGradient, HeroIllustration, NPMBadge } from '@theguild/components';
43
import gqlCodegenCover from '../../public/assets/illustrations/gql-codegen-cover.svg';
54
import gqlGenerateCodeIllustration from '../../public/assets/illustrations/gql-generate-code-illustration.svg';
65
import gqlWatchForChangesIllustration from '../../public/assets/illustrations/gql-watch-for-changes-illustration.svg';
76

8-
const LiveDemo = dynamic(() => import('@/components/live-demo/LiveDemo'), { ssr: false });
9-
107
export function IndexPage(): ReactElement {
118
return (
129
<>
1310
<HeroGradient
14-
title="Generate code from your GraphQL schema"
15-
description="Generate code from your GraphQL schema and operations with a simple CLI"
16-
link={{
17-
href: '/docs/getting-started/installation',
18-
children: 'Try It Now',
19-
title: 'Get started with GraphQL Code Generator',
20-
}}
21-
version={<NPMBadge name="@graphql-codegen/cli" />}
11+
title="Generate Type-Safe GraphQL Client and Server Code"
12+
description="Supercharge Your GraphQL Development Flow with Fully Typed Code in Seconds."
13+
link={[
14+
{
15+
href: '/docs/getting-started',
16+
children: 'Get Started with Client and Server',
17+
title: 'Get started with GraphQL Code Generator',
18+
},
19+
]}
2220
colors={['#1dbbff', '#ee1cd9']}
2321
image={{
2422
src: gqlCodegenCover,
@@ -28,8 +26,6 @@ export function IndexPage(): ReactElement {
2826
}}
2927
/>
3028

31-
<LiveDemo />
32-
3329
<HeroIllustration
3430
title="Generate Code Instantly"
3531
description="Generate code from your GraphQL schema and GraphQL operations with a single function call regardless of your environment or code format."

website/src/pages/docs/getting-started/index.mdx

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Introduction
33
description: GraphQL Code Generator is a plugin-based tool that helps you get the best out of your GraphQL stack. From back-end to front-end, GraphQL Code Generator automates the generation of typed Queries, Mutations and, Subscriptions for React, Vue, Angular, Next.js, Svelte, whether you are using Apollo Client, URQL or, React Query.
44
---
55

6-
import { Tabs, Callout } from '@theguild/components'
6+
import { Tabs, Callout, Cards} from '@theguild/components'
77

88
# Introduction to GraphQL Code Generator
99

@@ -40,7 +40,7 @@ type Query {
4040

4141
The following sections showcase why GraphQL Code Generator is a game-changer for your GraphQL Stack.
4242

43-
### From the front-end
43+
### From the Frontend
4444

4545
Most client-side implementations without GraphQL Code Generator would query the API as showcased in the following examples:
4646

@@ -250,13 +250,13 @@ Manually maintaining the GraphQL operation types or the complete absence of type
250250

251251
- **partial typing** of data (not all Schema&apos;s fields has a corresponding type)
252252

253-
The strength of your front-end application types is based on your data types.
253+
The strength of your frontend application types is based on your data types.
254254
Any mistake on your manually maintained data types ripples in many of your components.
255255

256256
For this reason, automating and generating the typing of your GraphQL operations will both improve the developer
257257
experience and stability of your stack.
258258

259-
After installing 3 packages:
259+
After installing GraphQL Code Generator:
260260

261261
```sh npm2yarn
262262
npm i graphql
@@ -385,7 +385,6 @@ const posts = computed(() => result.value?.posts);
385385
<Tabs.Tab>
386386
```tsx
387387
import { PostsGQL, PostsQuery } from './graphql'
388-
// BE SURE TO USE Observable from `rxjs` and not from `@apollo/client/core` when using map
389388
import { Observable } from 'rxjs'
390389
import { map } from 'rxjs/operators'
391390

@@ -436,7 +435,7 @@ GraphQL Code Generator checks for this automatically and will let you know if yo
436435
More details on the inner working of GraphQL Code Generator are available on [this page](/docs/advanced/how-does-it-work).
437436
</Callout>
438437

439-
### To the back-end
438+
### To the Backend
440439

441440
Most GraphQL API resolvers remain untyped or wrongly typed which, leads to multiple issues:
442441

@@ -527,15 +526,41 @@ export const resolvers: UsersModule.Resolvers = {
527526

528527
## What's next?
529528

530-
Start by [installing GraphQL Code Generator](/docs/getting-started/installation) in your project or get started with our guides:
531-
- [React and Vue](/docs/guides/react-vue)
532-
- [Vanilla TypeScript](/docs/guides/vanilla-typescript)
533-
- [Angular](/docs/guides/angular)
534-
- [Svelte](/docs/guides/svelte)
535-
- [Apollo and Yoga server](/docs/guides/graphql-server-apollo-yoga)
536-
- [GraphQL Modules](/docs/guides/graphql-modules)
529+
After unstanding the basic concepts of GraphQL Code Generator, you can start setting it up within your project.
530+
If your stack is not listed below, please refer to [our plugin overview](/plugins).
537531

538-
If your stack is not listed above, please refer to [our plugins directory](/plugins).
532+
### Client-Side GraphQL
533+
534+
Choose your existing setup or preference to get started.
535+
536+
<Cards>
537+
<Cards.Card arrow title="Vanilla TypeScript" href="/docs/guides/vanilla-typescript" />
538+
<Cards.Card arrow title="React Query" href="/docs/guides/react-query" />
539+
<Cards.Card arrow title="React / Vue" href="/docs/guides/react-vue" />
540+
<Cards.Card arrow title="Angular" href="/docs/guides/angular" />
541+
<Cards.Card arrow title="Svelte" href="/docs/guides/svelte" />
542+
</Cards>
543+
544+
### Server-Side GraphQL
545+
546+
547+
<Cards>
548+
<Cards.Card
549+
arrow
550+
title="GraphQL Yoga with Server Preset"
551+
href="/docs/guides/graphql-server-apollo-yoga-with-server-preset"
552+
/>
553+
<Cards.Card
554+
arrow
555+
title="Apollo Server with Server Preset"
556+
href="/docs/guides/graphql-server-apollo-yoga-with-server-preset"
557+
/>
558+
<Cards.Card arrow title="Apollo and Yoga server" href="/docs/guides/graphql-server-apollo-yoga" />
559+
<Cards.Card arrow title="GraphQL Modules" href="/docs/guides/graphql-modules" />
560+
</Cards>
561+
562+
563+
### Troubleshooting
539564

540565
If you are experiencing any issues, you can reach us via the following channels:
541566

website/src/pages/docs/getting-started/installation.mdx

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Quick Start
33
description: GraphQL Code Generator is a plugin-based tool that helps you get the best out of your GraphQL stack. From back-end to front-end, GraphQL Code Generator automates the generation of typed Queries, Mutations and, Subscriptions for React, Vue, Angular, Next.js, Svelte, whether you are using Apollo Client, URQL or, React Query.
44
---
55

6-
import { Callout } from '@theguild/components'
6+
import { Callout, Cards } from '@theguild/components'
77

88
# Quick Start
99

@@ -22,27 +22,22 @@ npm i -D @parcel/watcher
2222

2323
## Global Installation
2424

25-
<Callout type="warning">
2625
Please avoid installing `graphql`, `@graphql-codegen/cli`, and its plugins as global dependencies. This will cause issues because of duplications of the `graphql` package. Install it only locally in your project.
2726

28-
</Callout>
29-
3027
## Monorepo Project
3128

32-
<Callout type="warning">
33-
If you are using Monorepo setup (Lerna/Yarn Workspaces/anything else), please note that GraphQL Codegen is using `require` to load plugins and files. This might break and fail in case of hoisting.
29+
If you are using Monorepo setup (Yarn or pnpm Workspaces), please note that GraphQL Codegen is using `require` to load plugins and files. This might break and fail in case of hoisting.
3430

3531
If you are having issues with loading GraphQL-Codegen plugins, make sure it's installed correctly, at the same level of `node_modules`, and make sure it's accessible and available for the Codegen CLI.
3632

37-
</Callout>
33+
## Setup
3834

39-
GraphQL Code Generator comes with dozens of plugins, from front-end to back-end, from web apps to mobile apps. If you are not sure which plugins might be helpful for your GraphQL stack, give a try at the [_Initialization Wizard_](#initialization-wizard).
35+
GraphQL Code Generator comes with dozens of plugins, from frontend to backend, from web apps to mobile apps.
36+
We recommend looking at the [guides](#manual-setup) or trying the [initialization wizards](#initialization-wizard)
4037

4138
Otherwise, you can start exploring the [plugins](/plugins) and [setting up them manually](#manual-setup).
4239

43-
## Setup
44-
45-
### Initialization Wizard
40+
## Initialization Wizard
4641

4742
Once installed, GraphQL Code Generator CLI can help you configure your project based on some popular flows:
4843

@@ -56,25 +51,38 @@ npm install # install the chosen packages
5651

5752
Question by question, it will guide you through the whole process of setting up a schema, selecting and installing plugins, picking a destination to where your files are generated, and a lot more.
5853

59-
### Manual Setup
54+
## Manual Setup
6055

6156
Once GraphQL Code Generator is installed and added to your project's development workflow (scripts), you can start installing plugins and configuring them.
6257

6358
If you are looking for the **best way to leverage GraphQL Code Generator on your stack**, you should read one of our _Guides_.
6459

65-
#### Client
60+
### Client
61+
62+
Follow one of the following guides to get started.
63+
64+
<Cards>
65+
<Cards.Card arrow title="Vanilla TypeScript" href="/docs/guides/vanilla-typescript" />
66+
<Cards.Card arrow title="React Query" href="/docs/guides/react-query" />
67+
<Cards.Card arrow title="React / Vue" href="/docs/guides/react-vue" />
68+
<Cards.Card arrow title="Angular" href="/docs/guides/angular" />
69+
<Cards.Card arrow title="Svelte" href="/docs/guides/svelte" />
70+
</Cards>
6671

67-
We recommend using [a `client` preset](/plugins/presets/preset-client) that has a recommended configuration for the client applications. It's included in the `@graphql-codegen/cli` package by default. Follow one of the following guides to learn more:
72+
### Server
6873

69-
- [React](/docs/guides/react-vue)
70-
- [Vue](/docs/guides/react-vue)
71-
- [Angular](/docs/guides/angular)
72-
- [Svelte](/docs/guides/svelte)
74+
Follow one of the following guides to get started.
7375

74-
#### Server
76+
<Cards>
77+
<Cards.Card
78+
arrow
79+
title="Apollo and Yoga server with Server Preset"
80+
href="/docs/guides/graphql-server-apollo-yoga-with-server-preset"
81+
/>
82+
<Cards.Card arrow title="Apollo and Yoga server" href="/docs/guides/graphql-server-apollo-yoga" />
83+
<Cards.Card arrow title="GraphQL Modules" href="/docs/guides/graphql-modules" />
84+
</Cards>
7585

76-
- [Apollo and Yoga server](/docs/guides/graphql-server-apollo-yoga)
77-
- [Apollo and Yoga server with Server Preset](/docs/guides/graphql-server-apollo-yoga-with-server-preset)
78-
- [GraphQL Modules](/docs/guides/graphql-modules)
86+
### Other
7987

8088
If your stack is not listed above, please refer to [our plugins directory](/plugins).

website/src/pages/docs/guides/_meta.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default {
2-
'react-vue': 'React / Vue',
32
'vanilla-typescript': 'Vanilla TypeScript',
43
'react-query': 'React Query',
4+
'react-vue': 'React / Vue',
55
angular: 'Angular',
66
svelte: 'Svelte / Kit',
77
'flutter-freezed': 'Dart/Flutter',

website/src/pages/docs/guides/react-vue.mdx

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,9 @@ All the below code examples are available in our [repository `examples` folder](
4545

4646
For most GraphQL clients and frameworks (React, Vue), install the following packages:
4747

48-
**For Yarn:**
49-
50-
```bash
51-
yarn add graphql
52-
yarn add -D typescript ts-node @graphql-codegen/cli @graphql-codegen/client-preset @parcel/watcher
53-
```
54-
55-
**For npm:**
56-
57-
```bash
58-
npm i -S graphql
59-
npm i -D typescript ts-node @graphql-codegen/cli @graphql-codegen/client-preset @parcel/watcher
60-
```
61-
62-
**For pnpm:**
63-
64-
```bash
65-
pnpm i graphql @graphql-typed-document-node/core
66-
pnpm i -D typescript ts-node @graphql-codegen/cli @graphql-codegen/client-preset @parcel/watcher
48+
```sh npm2yarn
49+
npm install graphql
50+
npm install --dev typescript @graphql-codegen/cli @parcel/watcher
6751
```
6852

6953
<br />
@@ -75,7 +59,7 @@ Then provide the corresponding framework-specific configuration:
7559
<Tabs.Tab>
7660

7761
```ts filename="codegen.ts" {5}
78-
import { CodegenConfig } from '@graphql-codegen/cli'
62+
import type { CodegenConfig } from '@graphql-codegen/cli'
7963

8064
const config: CodegenConfig = {
8165
schema: 'https://swapi-graphql.netlify.app/.netlify/functions/index',
@@ -119,29 +103,16 @@ export default config
119103

120104
</Tabs>
121105

122-
> Each framework-specific lines are highlighted
123-
124-
<br />
125-
126-
<Callout type="info">
127-
128-
**Usage with `@tanstack/react-query`**
129-
130-
If you are using `@tanstack/react-query`, we recommend using it with `graphql-request@^5.0.0` to get the best developer experience.
131-
132-
If you are willing to provide your own fetcher, you can directly jump to the ["Appendix I: React Query with a custom fetcher
133-
setup"](#appendix-i-react-query-with-a-custom-fetcher-setup) and continue the guide once React Query is properly setup.
134-
135-
</Callout>
106+
> **Note**: For React Query, please refer to our [dedicated guide](/docs/guides/react-query).
136107
137108
<br />
138109

139110
## Writing GraphQL Queries
140111

141112
First, start GraphQL Code Generator in watch mode:
142113

143-
```
144-
yarn graphql-codegen --watch
114+
```sh npm2yarn
115+
npm run graphql-codegen --watch
145116
```
146117

147118
_Using GraphQL Code Generator will type your GraphQL Query and Mutations as you write them ⚡️_

0 commit comments

Comments
 (0)