Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit 9d50ccd

Browse files
okhorsunenko-lulaAndrii Chebukin
andcommitted
LHK-590 Added modern GraphQL Relay sample project with React (fsprojects#420)
Co-authored-by: Andrii Chebukin <andrii@lula.is>
1 parent fb6f128 commit 9d50ccd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4813
-9810
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
]
1010
},
1111
"fantomas": {
12-
"version": "5.1.4",
12+
"version": "5.2.0",
1313
"commands": [
1414
"fantomas"
1515
]

.github/workflows/publish_ci.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ on:
77

88
jobs:
99
publish:
10-
10+
1111
runs-on: ubuntu-latest
1212

1313
steps:
1414
- name: Checkout
1515
uses: actions/checkout@v3
16-
16+
1717
- name: Set Build Version
1818
run: |
1919
$File = (
@@ -24,10 +24,10 @@ jobs:
2424
$File.OwnerDocument.Save((Join-Path $PWD.ProviderPath Directory.Build.targets))
2525
echo "VERSION=$version" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
2626
shell: pwsh
27-
27+
2828
- name: Install .NET Core
2929
uses: actions/setup-dotnet@v3
30-
30+
3131
- name: Add the GitHub source
3232
run: dotnet nuget add source --username USERNAME --password ${{secrets.GITHUB_TOKEN}} --store-password-in-clear-text --name github "https://nuget.pkg.github.com/fsprojects/index.json"
3333

@@ -61,6 +61,14 @@ jobs:
6161
run: |
6262
dotnet nuget push nuget/*Server*.nupkg -s "github" -k ${{secrets.GITHUB_TOKEN}}
6363
64+
- name: Pack FSharp.Data.GraphQL.Server.Relay project
65+
run: |
66+
cd src/FSharp.Data.GraphQL.Server.Relay
67+
dotnet pack --no-build --nologo --configuration Release /p:IsNuget=true -o ../../nuget
68+
- name: Publish FSharp.Data.GraphQL.Server.Relay project to GitHub
69+
run: |
70+
dotnet nuget push nuget/*Server.Relay*.nupkg -s "github" -k ${{secrets.GITHUB_TOKEN}}
71+
6472
- name: Pack FSharp.Data.GraphQL.Server.Middleware project
6573
run: |
6674
cd src/FSharp.Data.GraphQL.Server.Middleware
@@ -82,4 +90,4 @@ jobs:
8290
run: |
8391
$path = "nuget/FSharp.Data.GraphQL.ProjectTemplates.$Env:VERSION.nupkg"
8492
dotnet nuget push $path -s "github" -k ${{secrets.GITHUB_TOKEN}}
85-
shell: pwsh
93+
shell: pwsh

.github/workflows/publish_release.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
with:
1616
# This is necessary so that we have the tags.
1717
fetch-depth: 0
18-
18+
1919
- name: Set Build Version
2020
run: |
2121
$version = "$env:GITHUB_REF_NAME"
@@ -60,6 +60,14 @@ jobs:
6060
run: |
6161
dotnet nuget push nuget/*Server*.nupkg -k ${{secrets.NUGET_SECRET}}
6262
63+
- name: Pack FSharp.Data.GraphQL.Server.Relay project
64+
run: |
65+
cd src/FSharp.Data.GraphQL.Server.Relay
66+
dotnet pack --no-build --nologo --configuration Release /p:IsNuget=true -o ../../nuget
67+
- name: Publish FSharp.Data.GraphQL.Server.Relay project to NuGet
68+
run: |
69+
dotnet nuget push nuget/*Server.Relay*.nupkg -k ${{secrets.NUGET_SECRET}}
70+
6371
- name: Pack FSharp.Data.GraphQL.Server.Middleware project
6472
run: |
6573
cd src/FSharp.Data.GraphQL.Server.Middleware
@@ -81,4 +89,4 @@ jobs:
8189
run: |
8290
$path = "nuget/FSharp.Data.GraphQL.ProjectTemplates.$Env:VERSION.nupkg"
8391
dotnet nuget push $path -k ${{secrets.NUGET_SECRET}}
84-
shell: pwsh
92+
shell: pwsh

FSharp.Data.GraphQL.sln

Lines changed: 151 additions & 123 deletions
Large diffs are not rendered by default.

Prepare template project for packing.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ $version = $dirBuildTargets.SelectSingleNode("//PropertyGroup[@Label='NuGet']/Ve
1010
[xml]$fsharpPackages = @"
1111
<ItemGroup Label="PackageReferences">
1212
<PackageReference Include="FSharp.Data.GraphQL.Server.Middleware" Version="$($version)" />
13+
<PackageReference Include="FSharp.Data.GraphQL.Server.Relay" Version="$($version)" />
1314
<PackageReference Include="FSharp.Data.GraphQL.Server" Version="$($version)" />
1415
<PackageReference Include="FSharp.Data.GraphQL.Shared" Version="$($version)" />
1516
</ItemGroup>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"passPerPreset": true,
3+
"presets": [
4+
{
5+
"plugins": [
6+
["relay", {
7+
"schema": "data/schema.json"}
8+
],
9+
"syntax-async-functions",
10+
"transform-class-properties",
11+
"transform-object-rest-spread",
12+
"react-require"
13+
]
14+
},
15+
"react",
16+
"es2015",
17+
"stage-0"
18+
]
19+
}

samples/relay-starter-kit/PATENTS renamed to samples/relay-modern-starter-kit/PATENTS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ necessarily infringed by the Software standing alone.
3030

3131
A "Patent Assertion" is any lawsuit or other action alleging direct, indirect,
3232
or contributory infringement or inducement to infringe any patent, including a
33-
cross-claim or counterclaim.
33+
cross-claim or counterclaim.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Relay Modern Starter Kit with Pagination
2+
3+
This kit includes an app server, a GraphQL server, and a transpiler that you can use to get started building an app with Relay. For a walkthrough, see the [Relay tutorial](https://facebook.github.io/relay/docs/tutorial.html).
4+
5+
Few changes have been made to the original starter kit. It is now compatible with the [Relay Modern](https://facebook.github.io/relay/docs/relay-modern.html) API version. It also uses a [PaginationContainer](https://facebook.github.io/relay/docs/PaginationContainer.html) for item retrieving.
6+
7+
## Installation
8+
9+
First install required npm modules:
10+
11+
```
12+
npm install
13+
```
14+
15+
Generate JavaScript sources of Relay-wrapped components by executing:
16+
17+
```
18+
npm run relay
19+
```
20+
21+
## Running
22+
23+
Start the GraphQL server by executing:
24+
25+
```
26+
fsharpi server.fsx
27+
```
28+
29+
Start the Relay application server:
30+
31+
```
32+
npm start
33+
```
34+
35+
Visit `localhost:8090` in your browser in order to access the application.
36+
37+
## Developing
38+
39+
### GraphQL Server
40+
41+
Following information supposed to get you started with modification of the GraphQL server.
42+
43+
#### Debugging
44+
45+
The sample contains a `server.fs` copy of the server and an F# project file which can be used for debugging with mono:
46+
47+
```
48+
xbuild && mono --debug --debugger-agent=transport=dt_socket,server=y,address=127.0.0.1:55555 ./bin/Debug/mono/FSharp.Data.GraphQL.ModernRelay.exe
49+
```
50+
51+
This will start the server awaiting for the mono debugger to be attached.
52+
53+
#### Uri
54+
55+
By default the server will start on `localhost:8083`. This can be modified by changing `address` and `port` in `server.fsx` or `server.fs` respectively. Changing this settings requires adjustment of `graphqlServerUri` in `./src/relayEnvironment.jsx`.
56+
57+
### Relay Application
58+
59+
#### Schema modification
60+
61+
Each time the schema is modified in the `server.fsx` GraphQL server, a new schema file has to be generated on the Relay application side.
62+
63+
Accessing the `localhost:8083` in your browser will yield an introspection reply containing the schema of the database. Save this response to `./data/schema.json` whenever the schema is getting changed.
64+
65+
Relay API has to know the path to the schema file. `.babelrc` contains this information by setting the `relay` plugin with `schema` option. Adjust this if the path to schema should change.
66+
67+
The generated `./data/schema.json` or `./data/schema.graphql` (see optional below) file is used for the ahead-of-time compilation by Relay Modern compiler. The compilation process should be triggered by executing:
68+
69+
```
70+
npm run relay
71+
```
72+
73+
The command checks relevant `.jsx` and `.js` files in `./src` folder and generates their compiled in `__generated__` for defined containers. Those are e.g. [FragmentContainer](https://facebook.github.io/relay/docs/fragment-container.html) or the root Relay tree [QueryRenderer](https://facebook.github.io/relay/docs/query-renderer.html).
74+
75+
#### Optional
76+
77+
There are two accepted schema formats: `.json` and `.graphql`. The conversion to the latter can be done by executing `npm run json-to-graphql`. Input and output files can be adjusted in `./scripts/jsonToGraphql.js`.
78+
79+
## License
80+
81+
Relay Starter Kit is [BSD licensed](./LICENSE). We also provide an additional [patent grant](./PATENTS).

0 commit comments

Comments
 (0)