|
1 | 1 | import * as prettier from "prettier";
|
2 | 2 | const code = `
|
| 3 | +Notice that the \`Trail\` component isn't receiving the entire \`trail\` object via props, only the \`id\` which is used along with the fragment document to create a live binding for each trail item in the cache. This allows each \`Trail\` component to react to the cache updates for a single trail independently. Updates to a trail's \`status\` will not cause the parent \`App\` component to rerender since the \`@nonreactive\` directive is applied to the \`TrailFragment\` spread, a fragment that includes the \`status\` field. |
3 | 4 |
|
| 5 | +<MinVersion version="3.12.0"> |
| 6 | +## \`@unmask\` |
| 7 | +</MinVersion> |
4 | 8 |
|
5 |
| -/** |
6 |
| - * A hook for executing queries in an Apollo application. |
7 |
| - * |
8 |
| - * To run a query within a React component, call \`useQuery\` and pass it a GraphQL query document. |
9 |
| - * |
10 |
| - * When your component renders, \`useQuery\` returns an object from Apollo Client that contains |
11 |
| - * |
12 |
| - * > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of \`useQuery\`. |
13 |
| - * |
14 |
| - * @example |
15 |
| - * \`\`\`jsx |
16 |
| - * import { gql } from '@apollo/client'; |
17 |
| - * import { useQuery } from '@apollo/client/react'; |
18 |
| - * |
19 |
| - * const GET_GREETING = gql\` |
20 |
| - * query GetGreeting($language: String!) { |
21 |
| - * greeting(language: $language) { |
22 |
| - * message |
23 |
| - * } |
24 |
| - * } |
25 |
| - * \`; |
26 |
| - * |
27 |
| - * function Hello() { |
28 |
| - * const { loading, error, data } = useQuery(GET_GREETING, { |
29 |
| - * variables: { language: 'english' }, |
30 |
| - * }); |
31 |
| - * if (loading) return <p>Loading ...</p>; |
32 |
| - * return <h1>Hello {data.greeting.message}!</h1>; |
33 |
| - * } |
34 |
| - * \`\`\` |
35 |
| - * @param query - A GraphQL query document parsed into an AST by \`gql\`. |
36 |
| - * @param options - Options to control how the query is executed. |
37 |
| - * @returns Query result object |
38 |
| - */ |
39 |
| -export function useQuery< |
40 |
| - TData = unknown, |
41 |
| - TVariables extends OperationVariables = OperationVariables, |
42 |
| ->( |
43 |
| - query: DocumentNode | TypedDocumentNode<TData, TVariables>, |
44 |
| - options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & { |
45 |
| - returnPartialData: true; |
46 |
| - } |
47 |
| -): useQuery.Result< |
48 |
| - TData, |
49 |
| - TVariables, |
50 |
| - "empty" | "complete" | "streaming" | "partial" |
51 |
| ->; |
| 9 | +The \`@unmask\` directive is used to make fragment data available when using [data masking](./fragments#data-masking). It is primarily used to [incrementally adopt data masking in an existing application](./fragments#incremental-adoption-in-an-existing-application). It is considered an escape hatch for all other cases where working with masked data would otherwise be difficult. |
52 | 10 |
|
53 |
| -/** {@inheritDoc @apollo/client!useQuery:function(1)} */ |
54 |
| -export function useQuery< |
55 |
| - TData = unknown, |
56 |
| - TVariables extends OperationVariables = OperationVariables, |
57 |
| ->( |
58 |
| - query: DocumentNode | TypedDocumentNode<TData, TVariables>, |
59 |
| - options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & { |
60 |
| - returnPartialData: boolean; |
| 11 | +\`\`\`graphql |
| 12 | +query GetPosts { |
| 13 | + posts { |
| 14 | + id |
| 15 | + ...PostDetails @unmask |
61 | 16 | }
|
62 |
| -): useQuery.Result< |
63 |
| - TData, |
64 |
| - TVariables, |
65 |
| - "empty" | "complete" | "streaming" | "partial" |
66 |
| ->; |
67 |
| -
|
68 |
| -/** {@inheritDoc @apollo/client!useQuery:function(1)} */ |
69 |
| -export function useQuery< |
70 |
| - TData = unknown, |
71 |
| -TVariables extends OperationVariables = OperationVariables, |
72 |
| ->( |
73 |
| -query: DocumentNode | TypedDocumentNode<TData, TVariables>, |
74 |
| -...[options]: {} extends TVariables ? |
75 |
| - [options?: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>] |
76 |
| -: [options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>] |
77 |
| -): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming">; |
| 17 | +} |
| 18 | +\`\`\` |
78 | 19 |
|
79 |
| -` |
80 |
| - .split("\n") |
81 |
| - .map((line) => line.trim()) |
82 |
| - .join("\n"); |
83 |
| -await prettier.format(``, { |
84 |
| - parser: "jsdoc", |
85 |
| - plugins: ["./format-jsdoc.js"], |
86 |
| -}); |
| 20 | +`; |
87 | 21 |
|
88 | 22 | const result = await prettier.format(code, {
|
89 |
| - parser: "typescript-with-jsdoc", |
90 |
| - plugins: ["./format-jsdoc.js"], |
| 23 | + parser: "mdx3", |
| 24 | + plugins: ["./format-mdx3.js"], |
91 | 25 | });
|
92 | 26 |
|
93 | 27 | console.log(result);
|
0 commit comments