Skip to content

Commit

Permalink
Universe: use Relay 13 and the new Rust Compiler
Browse files Browse the repository at this point in the history
This commit upgrades Relay to version 13 and switches from the old
Relay Compiler to the new Rust one (since both things go together).

Basically, the main change is that now we have only one Relay config
for the whole monorepo and the compiler is being executed for the whole
monorepo as well (while being much faster). Additionally, Relay support
is directly integrated into Flow so in many cases I simply removed
previous Flow types (see `useLazyLoadQuery` and `useFragment`).

There is still ongoing effort to improve the Flow types in Relay so not
everything is finalized. For this reason I decided to use "Compat" types
mode. Similarly, some hooks (`useMutation` and `usePreloadedQuery` for
example) still require explicit types information so I didn't change
these yet. Regardless of that, we are pretty close to use "Final" types.
We just need to wait for the Relay team to finish everything.

Many issues were already resolved but there are still some that need to
be fixed (not blocking this PR):

- facebook/relay#3700
- relayjs/eslint-plugin-relay#131
- prettier/prettier#6102

Important links with additional information:

- https://relay.dev/blog/2021/12/08/introducing-the-new-relay-compiler/
- https://github.com/facebook/relay/releases/tag/v13.0.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.0
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.1
- https://github.com/facebook/relay/releases/tag/v13.0.0-rc.2

adeira-source-id: bc3d10741250e32b6fd399245f62d25484c6ae70
  • Loading branch information
mrtnzlml authored and adeira-github-bot committed Jan 29, 2022
1 parent 5a2f0fe commit 94dfdc3
Show file tree
Hide file tree
Showing 48 changed files with 872 additions and 928 deletions.
11 changes: 0 additions & 11 deletions relay.config.js

This file was deleted.

7 changes: 3 additions & 4 deletions src/NavigationHeaderBadge.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import React, { type Node } from 'react';
import sx from '@adeira/sx';
import { graphql, useLazyLoadQuery } from '@adeira/relay';

import type { NavigationHeaderBadgeQuery } from './__generated__/NavigationHeaderBadgeQuery.graphql';

function ProdBadge(): Node {
return <span className={styles('prod')}>PROD</span>;
}
Expand All @@ -15,7 +13,8 @@ function DevBadge(): Node {
}

export default function NavigationHeaderBadge(): Node {
const data = useLazyLoadQuery<NavigationHeaderBadgeQuery>(
// eslint-disable-next-line relay/generated-flow-types -- https://github.com/relayjs/eslint-plugin-relay/issues/131
const data = useLazyLoadQuery(
graphql`
query NavigationHeaderBadgeQuery {
auth {
Expand All @@ -25,7 +24,7 @@ export default function NavigationHeaderBadge(): Node {
}
}
`,
{},
Object.freeze({}),
{
fetchPolicy: 'store-or-network',
},
Expand Down
50 changes: 26 additions & 24 deletions src/__generated__/AuthButtonsAuthorizeWebappMutation.graphql.js

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

50 changes: 27 additions & 23 deletions src/__generated__/AuthButtonsDeauthorizeWebappMutation.graphql.js

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

47 changes: 26 additions & 21 deletions src/__generated__/NavigationHeaderBadgeQuery.graphql.js

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

5 changes: 2 additions & 3 deletions src/analytics/AnalyticsRedirectsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import { Badge, Link, Table } from '@adeira/sx-design';
import React, { type Node } from 'react';
import { useLazyLoadQuery, graphql } from '@adeira/relay';

import type { AnalyticsRedirectsPageQuery } from './__generated__/AnalyticsRedirectsPageQuery.graphql';

export default function AnalyticsRedirectsPage(): Node {
const { analytics } = useLazyLoadQuery<AnalyticsRedirectsPageQuery>(graphql`
// eslint-disable-next-line relay/generated-flow-types -- https://github.com/relayjs/eslint-plugin-relay/issues/131
const { analytics } = useLazyLoadQuery(graphql`
query AnalyticsRedirectsPageQuery {
analytics {
redirectHits {
Expand Down
48 changes: 25 additions & 23 deletions src/analytics/__generated__/AnalyticsRedirectsPageQuery.graphql.js

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

4 changes: 2 additions & 2 deletions src/cats/CatsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import * as React from 'react';
import { graphql, useLazyLoadQuery } from '@adeira/relay';
import fbt from 'fbt';

import type { CatsPageQuery } from './__generated__/CatsPageQuery.graphql';
import CatsTableAdopted from './CatsTableAdopted';
import CatsTableCurrent from './CatsTableCurrent';

export default function CatsPage(): React.Node {
const data = useLazyLoadQuery<CatsPageQuery>(graphql`
// eslint-disable-next-line relay/generated-flow-types -- https://github.com/relayjs/eslint-plugin-relay/issues/131
const data = useLazyLoadQuery(graphql`
query CatsPageQuery {
cats {
...CatsTableCurrentFragment
Expand Down
Loading

0 comments on commit 94dfdc3

Please sign in to comment.