Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Add support for top level `@catch` on fragments on unions.
- Add parameter `excludedIds: array<dataId>` to `invalidateRecordsByIds` to allow excluding a list of connection IDs from invalidation.
- **BREAKING:** `operation.text` and `operation.id` are now nullable, which better reflects what values they can actually have in runtime.
- fix bug where custom scalars would error when set to null in refetch variables.

# 3.2.0

Expand Down
15 changes: 15 additions & 0 deletions packages/rescript-relay/__tests__/Test_refetching-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe("Fragment", () => {
test("refetching works", async () => {
queryMock.mockQuery({
name: "TestRefetchingQuery",
variables: { beforeDate: "2023-01-01T00:00:00.000Z" },
data: {
loggedInUser: {
id: "user-1",
Expand All @@ -18,6 +19,11 @@ describe("Fragment", () => {
friendsConnection: {
totalCount: 20,
},
friends: [
{
id: "user-2",
},
],
},
},
});
Expand All @@ -33,6 +39,7 @@ describe("Fragment", () => {
id: "user-1",
showOnlineStatus: true,
friendsOnlineStatuses: ["Online", "offline"],
beforeDate: null,
},
data: {
node: {
Expand All @@ -43,6 +50,14 @@ describe("Fragment", () => {
friendsConnection: {
totalCount: 10,
},
friends: [
{
id: "user-2",
},
{
id: "user-3",
},
],
},
},
});
Expand Down
17 changes: 14 additions & 3 deletions packages/rescript-relay/__tests__/Test_refetching.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module Query = %relay(`
query TestRefetchingQuery {
query TestRefetchingQuery($beforeDate: Datetime) {
loggedInUser {
...TestRefetching_user
...TestRefetching_user @arguments(
beforeDate: $beforeDate
)
}
}
`)
Expand All @@ -12,12 +14,16 @@ module Fragment = %relay(`
@argumentDefinitions(
friendsOnlineStatuses: { type: "[OnlineStatus!]" }
showOnlineStatus: { type: "Boolean", defaultValue: false }
beforeDate: { type: "Datetime" }
) {
firstName
onlineStatus @include(if: $showOnlineStatus)
friendsConnection(statuses: $friendsOnlineStatuses) {
totalCount
}
friends(beforeDate: $beforeDate) {
id
}
}
`)

Expand All @@ -34,7 +40,11 @@ module FragmentWithNoArgs = %relay(`
module Test = {
@react.component
let make = () => {
let query = Query.use(~variables=())
let query = Query.use(
~variables={
beforeDate: Js.Date.fromString("2023-01-01T00:00:00.000Z"),
},
)

let (data, refetch) = Fragment.useRefetchable(query.loggedInUser.fragmentRefs)

Expand All @@ -57,6 +67,7 @@ module Test = {
~variables=Fragment.makeRefetchVariables(
~showOnlineStatus=Some(true),
~friendsOnlineStatuses=Some([Online, Offline]),
~beforeDate=None,
),
)->RescriptRelay.Disposable.ignore
})
Expand Down

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

Loading
Loading