Skip to content

Commit 618ecb1

Browse files
committed
Update data-fetching.mdx
update GraphQL AS with tested code.
1 parent dbd8710 commit 618ecb1

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

modus/data-fetching.mdx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,19 +279,18 @@ import { graphql } from "@hypermode/modus-sdk-as"
279279
// the name of the GraphQL connection, as specified in the modus.json manifest
280280
const hostName: string = "my-graphql-api"
281281

282-
// Declare classes used to parse the JSON document returned
283-
@json
284-
class GetPersonResponse {
285-
getPerson: Person
286-
}
287-
282+
// Declare classes used to parse the JSON document returned
288283
@json
289284
class Person {
290285
name: string = ""
291286
age: i32 = 0
292287
}
288+
@json
289+
class GetPersonResponse {
290+
getPerson: Person | null
291+
}
293292

294-
export function getPerson(name: string): Person {
293+
export function getPerson(name: string): Person | null {
295294
const statement = `
296295
query getPerson($name: String!) {
297296
getPerson(name: $name) {

0 commit comments

Comments
 (0)