Skip to content

Commit f28ae31

Browse files
authored
Consistent client-preset examples naming (#9738)
1 parent 527da03 commit f28ae31

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

website/src/pages/plugins/presets/preset-client.mdx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ It also allows to colocate the Fragment definitions with their components counte
7777
import { FragmentType, useFragment } from './gql/fragment-masking'
7878
import { graphql } from '../src/gql'
7979

80-
export const FilmFragment = graphql(/* GraphQL */ `
80+
export const FilmItemFragment = graphql(/* GraphQL */ `
8181
fragment FilmItem on Film {
8282
id
8383
title
@@ -86,8 +86,8 @@ export const FilmFragment = graphql(/* GraphQL */ `
8686
}
8787
`)
8888

89-
const Film = (props: { film: FragmentType<typeof FilmFragment> }) => {
90-
const film = useFragment(FilmFragment, props.film)
89+
const Film = (props: { film: FragmentType<typeof FilmItemFragment> }) => {
90+
const film = useFragment(FilmItemFragment, props.film)
9191
return (
9292
<div>
9393
<h3>{film.title}</h3>
@@ -108,13 +108,13 @@ For an introduction on how to design your GraphQL Query to leverage Fragment Mas
108108

109109
As explained in [our guide](/docs/guides/react-vue), the top-level GraphQL Query should include the fragment (`...FilmItem`) and pass down the data to child components.
110110

111-
At the component props definition level, the `FragmentType<T>` type ensures that the passed data contains the required fragment (here: `FilmFragment` aka `FilmItem` in GraphQL).
111+
At the component props definition level, the `FragmentType<T>` type ensures that the passed data contains the required fragment (here: `FilmItemFragment` aka `FilmItem` in GraphQL).
112112

113113
```tsx filename="src/Film.tsx" {14-15}
114114
import { FragmentType, useFragment } from './gql/fragment-masking'
115115
import { graphql } from '../src/gql'
116116

117-
export const FilmFragment = graphql(/* GraphQL */ `
117+
export const FilmItemFragment = graphql(/* GraphQL */ `
118118
fragment FilmItem on Film {
119119
id
120120
title
@@ -125,9 +125,9 @@ export const FilmFragment = graphql(/* GraphQL */ `
125125

126126
const Film = (props: {
127127
/* the passed `film` property contains a valid `FilmItem` fragment 🎉 */
128-
film: FragmentType<typeof FilmFragment>
128+
film: FragmentType<typeof FilmItemFragment>
129129
}) => {
130-
const film = useFragment(FilmFragment, props.film)
130+
const film = useFragment(FilmItemFragment, props.film)
131131
return (
132132
<div>
133133
<h3>{film.title}</h3>
@@ -152,13 +152,13 @@ as described in [the next section](#getting-a-fragments-type).
152152

153153
#### The `useFragment()` helper
154154

155-
The `useFragment()` function helps narrow down the Fragment type from a given data object (ex: `film` object to a `FilmFragment` object):
155+
The `useFragment()` function helps narrow down the Fragment type from a given data object (ex: `film` object to a `FilmItemFragment` object):
156156

157157
```tsx filename="src/Film.tsx" {14-15}
158158
import { FragmentType, useFragment } from './gql/fragment-masking'
159159
import { graphql } from '../src/gql'
160160

161-
export const FilmFragment = graphql(/* GraphQL */ `
161+
export const FilmItemFragment = graphql(/* GraphQL */ `
162162
fragment FilmItem on Film {
163163
id
164164
title
@@ -167,8 +167,8 @@ export const FilmFragment = graphql(/* GraphQL */ `
167167
}
168168
`)
169169

170-
const Film = (props: { film: FragmentType<typeof FilmFragment> }) => {
171-
const film = useFragment(FilmFragment, props.film)
170+
const Film = (props: { film: FragmentType<typeof FilmItemFragment> }) => {
171+
const film = useFragment(FilmItemFragment, props.film)
172172
// `film` is of type `FilmItemFragment` 🎉
173173
return (
174174
<div>
@@ -237,7 +237,7 @@ Or, if you have access to the Fragment's definition, you can extract the type fr
237237
```tsx filename="src/Film.tsx" {1, 3, 12}
238238
import { ResultOf } from '@graphql-typed-document-node/core'
239239

240-
export const FilmFragment = graphql(/* GraphQL */ `
240+
export const FilmItemFragment = graphql(/* GraphQL */ `
241241
fragment FilmItem on Film {
242242
id
243243
title
@@ -246,7 +246,7 @@ export const FilmFragment = graphql(/* GraphQL */ `
246246
}
247247
`)
248248

249-
function myFilmHelper(film: ResultOf<typeof FilmFragment>) {
249+
function myFilmHelper(film: ResultOf<typeof FilmItemFragment>) {
250250
// ...
251251
}
252252
```

0 commit comments

Comments
 (0)