Skip to content

Commit 8394c8b

Browse files
BrookkeBrooke Hattoneddeee888
authored
docs(vanilla typescript): Fix the return type of the exec function (#10360)
* docs(vanilla typescript): Fix the return type of the exec function When working through the vanilla typescript example I found that the shape of the data actually returned by the fetch was `result.data. * run prettier * improve type import --------- Co-authored-by: Brooke Hatton <[email protected]> Co-authored-by: Brooke Hatton <[email protected]> Co-authored-by: Eddy Nguyen <[email protected]>
1 parent 3188b8c commit 8394c8b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

website/src/pages/docs/guides/vanilla-typescript.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ We can build a simple wrapper around `fetch` that takes a `TypedDocumentString`
181181
returns a typed response.
182182

183183
```typescript filename="src/graphql/execute.ts"
184+
import type { ExecutionResult } from 'graphql'
184185
import type { TypedDocumentString } from './graphql'
185186

186187
export async function execute<TResult, TVariables>(
@@ -203,7 +204,7 @@ export async function execute<TResult, TVariables>(
203204
throw new Error('Network response was not ok')
204205
}
205206

206-
return response.json() as TResult
207+
return response.json() as ExecutionResult<TResult>
207208
}
208209
```
209210

0 commit comments

Comments
 (0)