Skip to content

Commit

Permalink
upgrade example to 0.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zth committed Mar 10, 2021
1 parent 7915ed1 commit bfb9040
Show file tree
Hide file tree
Showing 23 changed files with 136 additions and 147 deletions.
4 changes: 2 additions & 2 deletions example/bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
}
],
"suffix": ".bs.js",
"ppx-flags": ["reason-relay/ppx"],
"ppx-flags": ["rescript-relay/ppx"],
"namespace": true,
"bs-dependencies": [
"@rescript/react",
"reason-relay",
"rescript-relay",
"bs-fetch",
"reason-promise"
],
Expand Down
14 changes: 7 additions & 7 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"bs:watch": "bsb -make-world -w",
"bs:clean": "bsb -clean-world",
"webpack": "webpack-dev-server",
"relay": "reason-relay-compiler",
"relay:watch": "reason-relay-compiler --watch"
"relay": "rescript-relay-compiler",
"relay:watch": "rescript-relay-compiler --watch"
},
"dependencies": {
"@mdi/font": "3.7.95",
Expand All @@ -20,13 +20,13 @@
"graphql": "^14.5.8",
"react": "0.0.0-experimental-4e08fb10c",
"react-dom": "0.0.0-experimental-4e08fb10c",
"react-relay": "0.0.0-experimental-4c4107dd",
"react-relay": "11.0.0",
"reason-promise": "^1.1.1",
"@rescript/react": "0.10.1",
"reason-relay": "0.15.0",
"relay-compiler": "10.1.3",
"relay-config": "10.1.3",
"relay-runtime": "10.1.3",
"rescript-relay": "0.16.0",
"relay-compiler": "11.0.0",
"relay-config": "11.0.0",
"relay-runtime": "11.0.0",
"subscriptions-transport-ws": "^0.9.18"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions example/src/Index.res
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* This mounts the app to the DOM. Note that the environment is
* passed to context via <ReasonRelay.Context.Provider /> here -
* passed to context via <RescriptRelay.Context.Provider /> here -
* it's a requirement that the environment is available in the
* context.
*/
ReactExperimental.renderConcurrentRootAtElementWithId(
<ReasonRelay.Context.Provider environment=RelayEnv.environment>
<RescriptRelay.Context.Provider environment=RelayEnv.environment>
<App />
</ReasonRelay.Context.Provider>,
</RescriptRelay.Context.Provider>,
"app",
)
12 changes: 6 additions & 6 deletions example/src/RelayEnv.res
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Graphql_error(string)
* A standard fetch that sends our operation and variables to the
* GraphQL server, and then decodes and returns the response.
*/
let fetchQuery: ReasonRelay.Network.fetchFunctionPromise = (
let fetchQuery: RescriptRelay.Network.fetchFunctionPromise = (
operation,
variables,
_cacheConfig,
Expand Down Expand Up @@ -54,14 +54,14 @@ let subscriptionClient = SubscriptionsTransportWs.createSubscriptionClient(
{"reconnect": true},
)

let subscriptionFunction: ReasonRelay.Network.subscribeFn = (config, variables, _cacheConfig) => {
let subscriptionFunction: RescriptRelay.Network.subscribeFn = (config, variables, _cacheConfig) => {
let query = config.text
let subscriptionQuery: SubscriptionsTransportWs.operationOptions = {
query: query,
variables: variables,
}

ReasonRelay.Observable.make(sink => {
RescriptRelay.Observable.make(sink => {
let observable = subscriptionClient["request"](subscriptionQuery)
let subscription = observable["subscribe"](sink)
Some(subscription)
Expand All @@ -73,7 +73,7 @@ let subscriptionFunction: ReasonRelay.Network.subscribeFn = (config, variables,
* layer here, but Relay also has own observables that you could set up
* your network layer to use instead of promises.
*/
let network = ReasonRelay.Network.makePromiseBased(
let network = RescriptRelay.Network.makePromiseBased(
~fetchFunction=fetchQuery,
~subscriptionFunction,
(),
Expand All @@ -89,8 +89,8 @@ let network = ReasonRelay.Network.makePromiseBased(
* when you have a GraphQL server where ids are not globally unique for
* example.
*/
let environment = ReasonRelay.Environment.make(
let environment = RescriptRelay.Environment.make(
~network,
~store=ReasonRelay.Store.make(~source=ReasonRelay.RecordSource.make(), ()),
~store=RescriptRelay.Store.make(~source=RescriptRelay.RecordSource.make(), ()),
(),
)
10 changes: 5 additions & 5 deletions example/src/SubscriptionsTransportWs.res
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Minimal required binding for subscriptions-transport-ws
* Note that those bindings are ReasonRelay-specific, and
* Note that those bindings are RescriptRelay-specific, and
* would need to be adjusted in order to be used for
* other purposes
*/
Expand All @@ -10,13 +10,13 @@ type operationOptions = {
}

type observable<'a> = {
@bs.meth
"subscribe": ReasonRelay.Observable.sink<'a> => ReasonRelay.Observable.subscription,
@meth
"subscribe": RescriptRelay.Observable.sink<'a> => RescriptRelay.Observable.subscription,
}

type t<'a> = {@bs.meth "request": operationOptions => observable<'a>}
type t<'a> = {@meth "request": operationOptions => observable<'a>}

@bs.new @bs.module("subscriptions-transport-ws")
@new @module("subscriptions-transport-ws")
external createSubscriptionClient: (string, 'a) => t<'b> = "SubscriptionClient"

let createSubscriptionClient = createSubscriptionClient
14 changes: 5 additions & 9 deletions example/src/TodoList.res
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module TodoListFragment = %relay(
`
module TodoListFragment = %relay(`
fragment TodoList_query on Query
@argumentDefinitions(
first: { type: "Int!", defaultValue: 10 }
Expand All @@ -16,11 +15,9 @@ module TodoListFragment = %relay(
}
}
}
`
)
`)

module AddTodoMutation = %relay(
`
module AddTodoMutation = %relay(`
mutation TodoListAddTodoMutation(
$input: AddTodoItemInput!
$connections: [ID!]!
Expand All @@ -35,8 +32,7 @@ module AddTodoMutation = %relay(
}
}
}
`
)
`)

@react.component
let make = (~query as queryRef) => {
Expand Down Expand Up @@ -65,7 +61,7 @@ let make = (~query as queryRef) => {
addedTodoItemEdge: Some({
node: Some({
id: {
open ReasonRelay
open RescriptRelay
generateUniqueClientID()->dataIdToString
},
text: newTodoText,
Expand Down
16 changes: 6 additions & 10 deletions example/src/TopCardsDisplayer.res
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@
* This is a pretty basic fragment, there are more complex ones you can have
* a look at in other components.
*/
module SiteStatisticsFragment = %relay(
`
module SiteStatisticsFragment = %relay(`
fragment TopCardsDisplayer_siteStatistics on SiteStatistics {
weeklySales
weeklyOrders
currentVisitorsOnline
}
`
)
`)

module CurrentVisitorsSubscription = %relay(
`
module CurrentVisitorsSubscription = %relay(`
subscription TopCardsDisplayer_currentVisitorsOnline_Subscription {
siteStatisticsUpdated {
currentVisitorsOnline
}
}
`
)
`)

/**
* A few things to note about the following component:
Expand All @@ -40,7 +36,7 @@ module CurrentVisitorsSubscription = %relay(
let make = (~siteStatistics as siteStatisticsRef) => {
let siteStatistics = SiteStatisticsFragment.use(siteStatisticsRef)

let environment = ReasonRelay.useEnvironmentFromContext()
let environment = RescriptRelay.useEnvironmentFromContext()
React.useEffect0(() => {
let subscription = CurrentVisitorsSubscription.subscribe(
~environment,
Expand All @@ -59,7 +55,7 @@ let make = (~siteStatistics as siteStatisticsRef) => {
(),
)

Some(() => ReasonRelay.Disposable.dispose(subscription))
Some(() => RescriptRelay.Disposable.dispose(subscription))
})

<div className="row">
Expand Down
6 changes: 3 additions & 3 deletions example/src/__generated__/Avatar_user_graphql.res

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions example/src/__generated__/MainQuery_graphql.res

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions example/src/__generated__/RecentTicketsRefetchQuery_graphql.res

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bfb9040

Please sign in to comment.