-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* support input unions * not needed * the correct fork commit * changelog * add test case for oneOf fields * docs for input unions
- Loading branch information
Showing
11 changed files
with
405 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
packages/rescript-relay/__tests__/Test_inputUnion-tests.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require("@testing-library/jest-dom/extend-expect"); | ||
const t = require("@testing-library/react"); | ||
const React = require("react"); | ||
const queryMock = require("./queryMock"); | ||
|
||
const { test_inputUnion } = require("./Test_inputUnion.bs"); | ||
|
||
describe("Query", () => { | ||
test("conversion of input unions work", async () => { | ||
queryMock.mockQuery({ | ||
name: "TestInputUnionQuery", | ||
variables: { | ||
location: { | ||
byAddress: { | ||
city: "City", | ||
}, | ||
}, | ||
}, | ||
data: { | ||
findByLocation: "Got it", | ||
}, | ||
}); | ||
|
||
queryMock.mockQuery({ | ||
name: "TestInputUnionQuery", | ||
variables: { | ||
location: { | ||
byId: "<id>", | ||
}, | ||
}, | ||
data: { | ||
findByLocation: "Got ID", | ||
}, | ||
}); | ||
|
||
t.render(test_inputUnion()); | ||
await t.screen.findByText("Got it"); | ||
await t.screen.findByText("Got ID"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module Query = %relay(` | ||
query TestInputUnionQuery($location: Location!) { | ||
findByLocation(location: $location) | ||
} | ||
`) | ||
|
||
module Test = { | ||
@react.component | ||
let make = () => { | ||
let data = Query.use( | ||
~variables={ | ||
location: ByAddress({city: "City"}), | ||
}, | ||
) | ||
|
||
let data2 = Query.use( | ||
~variables={ | ||
location: ById("<id>"), | ||
}, | ||
) | ||
|
||
<> | ||
<div> {React.string(data.findByLocation->Belt.Option.getWithDefault("-"))} </div> | ||
<div> {React.string(data2.findByLocation->Belt.Option.getWithDefault("-"))} </div> | ||
</> | ||
} | ||
} | ||
|
||
@live | ||
let test_inputUnion = () => { | ||
let network = RescriptRelay.Network.makePromiseBased(~fetchFunction=RelayEnv.fetchQuery) | ||
|
||
let environment = RescriptRelay.Environment.make( | ||
~network, | ||
~store=RescriptRelay.Store.make(~source=RescriptRelay.RecordSource.make()), | ||
) | ||
|
||
<TestProviders.Wrapper environment> | ||
<Test /> | ||
</TestProviders.Wrapper> | ||
} |
34 changes: 34 additions & 0 deletions
34
packages/rescript-relay/__tests__/__generated__/RelaySchemaAssets_graphql.res
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
149 changes: 149 additions & 0 deletions
149
packages/rescript-relay/__tests__/__generated__/TestInputUnionQuery_graphql.res
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.