Skip to content

Commit

Permalink
Update scalars documentation for null values (HoudiniGraphql#1041)
Browse files Browse the repository at this point in the history
  • Loading branch information
fnimick committed Apr 5, 2023
1 parent 2af5eb9 commit 744f3b9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions site/src/routes/api/config/+page.svx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ export default {
DateTime: {
type: 'Date',
unmarshal(val) {
return new Date(val)
return val ? new Date(val) : null
},
marshal(date) {
return date.getTime()
return date && date.getTime()
}
}
}
Expand Down Expand Up @@ -109,17 +109,20 @@ export default {
type: 'Date',
// turn the api's response into that type
unmarshal(val) {
return new Date(val)
return val ? new Date(val) : null
},
// turn the value into something the API can use
marshal(date) {
return date.getTime()
return date && date.getTime()
}
}
}
}
```

Please note that your marshal/unmarshal functions are also called with null
values, and these must be handled appropriately.

## Schema Polling

You can configure your development server to poll a remote URL for changes in your schema using the `watchSchema`
Expand Down

0 comments on commit 744f3b9

Please sign in to comment.