Skip to content

Commit 47f7c25

Browse files
authored
fix remove-unused-fields command (#636)
* fix remove-unused-fields command - make it use rescript-tools from the installed rescript package instead of relying on the outdated @rescript/tools package - get the artifact directory from relay config - do not analyze files in relay config `excludes` * fix typo * update rescript to v12.3.0 * add E2E test for remove-unused-fields
1 parent 61152e7 commit 47f7c25

22 files changed

Lines changed: 823 additions & 53 deletions

.github/workflows/cli.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,35 @@ jobs:
1515
working-directory: packages/rescript-relay-cli
1616
steps:
1717
- uses: actions/checkout@v4
18+
with:
19+
submodules: "true"
1820
- uses: actions/setup-node@v4
1921
with:
2022
node-version: 23
2123
env:
2224
CI: true
25+
- name: Set up OCaml
26+
uses: ocaml/setup-ocaml@v3
27+
with:
28+
ocaml-compiler: "4.14"
29+
dune-cache: true
30+
cache-prefix: "v1"
31+
- name: Install PPX dependencies
32+
working-directory: packages/rescript-relay/rescript-relay-ppx
33+
run: opam install . --deps-only
34+
- name: Build PPX
35+
working-directory: packages/rescript-relay/rescript-relay-ppx
36+
run: opam exec -- dune build bin/RescriptRelayPpxApp.exe
2337
- name: Install
2438
run: |
2539
yarn --frozen-lockfile
2640
- name: Build
2741
run: |
2842
yarn build
43+
- name: Build local Relay compiler
44+
working-directory: packages/rescript-relay
45+
run: |
46+
./build-compiler-dev.sh
2947
- name: Test
3048
run: |
3149
yarn test

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# master
2+
3+
- fix remove-unused-fields command. https://github.com/zth/rescript-relay/pull/636
4+
15
# 4.5.1
26

37
- Fix `traverse` exiting after a custom-scalar field (single array-backed `c`, or `ca`), leaving subsequent fields on the same parent uncoerced. Surfaced as raw `null` for nullable response fields, raw ReScript values for unserialized variables, and (in nested input objects) silently skipped converters. Closes #582; extends #434's #407 fix so trailing fields are preserved.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.cli-dist/
2+
.yarn/
3+
.pnp.*
4+
lib/
5+
node_modules/
6+
packages/*/lib/
7+
packages/*/node_modules/
8+
packages/web/src/__relay__/*
9+
!.gitkeep
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "remove-unused-fields-monorepo",
3+
"version": "1.0.0",
4+
"private": true,
5+
"workspaces": [
6+
"packages/*"
7+
],
8+
"scripts": {
9+
"relay": "yarn --cwd packages/web relay",
10+
"rescript:build": "rescript build",
11+
"reanalyze": "rescript-tools reanalyze -dce"
12+
},
13+
"dependencies": {
14+
"fixture-web": "1.0.0"
15+
},
16+
"devDependencies": {
17+
"@rescript/react": "0.14.0",
18+
"graphql": "15.8.0",
19+
"react": "18.2.0",
20+
"react-relay": "20.1.1",
21+
"relay-runtime": "20.1.1",
22+
"rescript": "12.3.0",
23+
"rescript-relay": "file:../../../../rescript-relay"
24+
}
25+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "fixture-web",
3+
"version": "1.0.0",
4+
"private": true,
5+
"scripts": {
6+
"relay": "rescript-relay-compiler"
7+
},
8+
"dependencies": {
9+
"@rescript/react": "0.14.0",
10+
"react": "18.2.0",
11+
"react-relay": "20.1.1",
12+
"relay-runtime": "20.1.1",
13+
"rescript": "12.3.0",
14+
"rescript-relay": "file:../../../../../../rescript-relay"
15+
}
16+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
src: "./src",
3+
schema: "./schema.graphql",
4+
artifactDirectory: "./src/__relay__",
5+
language: "rescript",
6+
excludes: ["**/lib/**"],
7+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "fixture-web",
3+
"sources": [
4+
{
5+
"dir": "compiled",
6+
"subdirs": true
7+
},
8+
{
9+
"dir": "src/__relay__",
10+
"subdirs": true
11+
}
12+
],
13+
"dependencies": [
14+
"rescript-relay"
15+
],
16+
"package-specs": {
17+
"module": "commonjs",
18+
"in-source": false
19+
},
20+
"suffix": ".js",
21+
"namespace": true
22+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
schema {
2+
query: Query
3+
}
4+
5+
interface Node {
6+
id: ID!
7+
}
8+
9+
type Query {
10+
organization(id: ID!): Organization
11+
currentOrg: Organization!
12+
}
13+
14+
type Organization implements Node {
15+
id: ID!
16+
name: String!
17+
currentUserIsAdmin: Boolean!
18+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module Query = %relay(`
2+
query IndexQuery {
3+
currentOrg {
4+
...OrganizationCard
5+
}
6+
}
7+
`)
8+
9+
@react.component
10+
let make = () => {
11+
let {currentOrg: {fragmentRefs}} = Query.use()
12+
13+
<OrganizationCard fragmentRefs />
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module Fragment = %relay(`
2+
fragment OrganizationCard on Organization {
3+
id
4+
name
5+
currentUserIsAdmin
6+
}
7+
`)
8+
9+
@react.component
10+
let make = (~fragmentRefs) => {
11+
let {name} = Fragment.use(fragmentRefs)
12+
13+
React.string(name)
14+
}

0 commit comments

Comments
 (0)