Skip to content

Commit

Permalink
Relay 18.2 (#542)
Browse files Browse the repository at this point in the history
* up packages, and pull latest compiler

* bind waitForFragmentData

* 3.1.0

* add experimental non React mode to the PPX

* fix inclusion

* changelog

* up docs
  • Loading branch information
zth authored Dec 14, 2024
1 parent fd9f8d9 commit 2a6cb0f
Show file tree
Hide file tree
Showing 31 changed files with 668 additions and 181 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# master

# 3.1.0

This brings the Relay version to `18.2.0`.

If you have enabled the feature flags in `relay.config.js` for aliased fragments or Relay resolvers you'll need to remove them from the config file as they are now on by default, and not removing them will cause the compiler to fail with a non super helpful error message.

- **Upgrade versions**: `react-relay` and `relay-runtime` to `18.2.0`.
- Add support for `Fragment.waitForFragmentData`, a new API in Relay 18.2 that lets you wait for fragment data outside of React.
- Experimental: Add a "non React" mode to the PPX, which makes sure only APIs that don't rely on React directly are exposed. This is intended to be a way to simplify using RescriptRelay without React. Activate by passing `-non-react` to the PPX, like `"ppx-flags": [["rescript-relay/ppx", "-non-react"]]`.

# 3.0.1

- Add `Environment.findAllConnectionIds` for finding all IDs of all connection instances for a specific connection, regardless of what configs that connection has been fetched (and cached) with.
Expand Down
2 changes: 1 addition & 1 deletion packages/relay
Submodule relay updated 2882 files
25 changes: 25 additions & 0 deletions packages/rescript-relay/__tests__/Test_nonReact-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require("@testing-library/jest-dom/extend-expect");
const queryMock = require("./queryMock");

const { test_nonReact } = require("./Test_nonReact.bs");

describe("Fragment", () => {
test("waitForFragmentData works", async () => {
queryMock.mockQuery({
name: "TestNonReactQuery",
data: {
loggedInUser: {
id: "user-1",
firstName: "First",
onlineStatus: "Online",
},
},
});

const res = await test_nonReact();
expect(res.waitForFragmentData).toEqual({
firstName: "First",
onlineStatus: "Online",
});
});
});
35 changes: 35 additions & 0 deletions packages/rescript-relay/__tests__/Test_nonReact.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module Query = %relay(`
query TestNonReactQuery {
loggedInUser {
firstName
...TestNonReact_user
}
}
`)

module Fragment = %relay(`
fragment TestNonReact_user on User {
firstName
onlineStatus
}
`)

@live
let test_nonReact = async () => {
let network = RescriptRelay.Network.makePromiseBased(~fetchFunction=RelayEnv.fetchQuery)

let environment = RescriptRelay.Environment.make(
~network,
~store=RescriptRelay.Store.make(~source=RescriptRelay.RecordSource.make()),
)

let query = await Query.fetchPromised(~environment, ~variables=())
let fragmentData = await Fragment.waitForFragmentData(
~environment,
query.loggedInUser.fragmentRefs,
)

{
"waitForFragmentData": fragmentData,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Logger = {

let getLoggedArg = () => loggedArg.contents

let expectedArg: RescriptRelay.RelayFieldLogger.arg = MissingFieldLog({
let expectedArg: RescriptRelay.RelayFieldLogger.arg = MissingRequiredFieldLog({
owner: "TestRequiredFieldLoggerQuery",
fieldPath: "loggedInUser.firstName",
})
Expand Down

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

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

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

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

Loading

0 comments on commit 2a6cb0f

Please sign in to comment.