Skip to content

Commit

Permalink
v3.0.0 examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jeddeloh committed Jan 21, 2022
1 parent a7ae180 commit 7b167c5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion EXAMPLES/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"react": "16.13.1",
"react-dom": "16.13.1",
"reason-promise": "1.1.1",
"rescript-apollo-client": "2.4.1",
"rescript-apollo-client": "3.0.0",
"subscriptions-transport-ws": "0.9.16"
}
}
1 change: 1 addition & 0 deletions EXAMPLES/src/Ignore.res
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let promise: Js.Promise.t<'a> => unit = ignore
22 changes: 9 additions & 13 deletions EXAMPLES/src/docs/Docs.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
This file used for formatting/typechecking of code snippets on the documentation website
*/

module TodosQuery = %graphql(
`
module TodosQuery = %graphql(`
query TodosQuery {
todos: allTodos {
id
text
completed
}
}
`
)
`)

module Basics = {
@react.component
Expand Down Expand Up @@ -67,7 +65,9 @@ module Lazy = {
{switch queryResult {
| Unexecuted(_) => <>
{"Waiting to be executed... "->React.string}
<button onClick={_ => executeQuery()} value="execute"> {"Execute"->React.string} </button>
<button onClick={_ => executeQuery()->Ignore.promise} value="execute">
{"Execute"->React.string}
</button>
</>
| Executed({loading: true, data: None}) => <p> {"Loading"->React.string} </p>
| Executed({loading, data: Some({todos}), error}) => <>
Expand All @@ -88,17 +88,15 @@ module Lazy = {
}
}

module AddTodoMutation = %graphql(
`
module AddTodoMutation = %graphql(`
mutation AddTodo($text: String!) {
todo: addTodoSimple(text: $text) {
id
completed
text
}
}
`
)
`)

module MutationBasics = {
@react.component
Expand Down Expand Up @@ -185,15 +183,13 @@ module MutationTypical = {
}
}

module StatsSubscription = %graphql(
`
module StatsSubscription = %graphql(`
subscription SorryItsNotASubscriptionForTodos {
siteStatisticsUpdated {
currentVisitorsOnline
}
}
`
)
`)

module Subscription = {
@react.component
Expand Down
4 changes: 3 additions & 1 deletion EXAMPLES/src/hooksUsage/Query_Lazy.res
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ let make = () => {
{switch queryResult {
| Unexecuted(_) => <>
{"Waiting to be executed... "->React.string}
<button onClick={_ => executeQuery()} value="execute"> {"Execute"->React.string} </button>
<button onClick={_ => executeQuery()->Ignore.promise} value="execute">
{"Execute"->React.string}
</button>
</>
| Executed({loading: true, data: None}) => <p> {"Loading"->React.string} </p>
| Executed({loading, data: Some({todos}), error}) => <>
Expand Down

0 comments on commit 7b167c5

Please sign in to comment.