forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMutation.tsx
More file actions
45 lines (40 loc) · 1.4 KB
/
Mutation.tsx
File metadata and controls
45 lines (40 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { useRouter } from 'next/router'
import { Link } from 'components/Link'
import { GraphqlItem } from './GraphqlItem'
import { Notice } from './Notice'
import { useTranslation } from 'src/languages/components/useTranslation'
import { Table } from './Table'
import type { MutationT } from './types'
import React from 'react'
type Props = {
item: MutationT
}
export function Mutation({ item }: Props) {
const { locale } = useRouter()
const { t } = useTranslation('products')
const heading = t('graphql.reference.input_fields').replace('{{ GraphQLItemTitle }}', item.name)
const heading2 = t('graphql.reference.return_fields').replace('{{ GraphQLItemTitle }}', item.name)
return (
<GraphqlItem item={item} heading={heading}>
{item.inputFields.map((input) => (
<React.Fragment key={input.id}>
<ul>
<li>
<code>{input.name}</code> (
<code>
<Link href={input.href} locale={locale}>
{input.type}
</Link>
</code>
)
</li>
</ul>
{input.preview && <Notice item={input} variant="preview" />}
{input.isDeprecated && <Notice item={input} variant="deprecation" />}
<h4 dangerouslySetInnerHTML={{ __html: heading2 }} />
<Table fields={item.returnFields} />
</React.Fragment>
))}
</GraphqlItem>
)
}