Skip to content

Commit

Permalink
Relay: use version 11.0.0-rc.0
Browse files Browse the repository at this point in the history
This is a first step in modernization of `@adeira/relay`. I tried to keep backward compatibility as much as possible so it should work without any changes. However, there is no plan to release a new `@adeira/relay` version until Relay itself is stable.

See:

- https://github.com/facebook/relay/releases/tag/v11.0.0-rc.0
- facebook/relay#3371

adeira-source-id: 94550a99ad8fe2d73d054360ac34addae21d54f4
  • Loading branch information
mrtnzlml authored and adeira-github-bot committed Mar 3, 2021
1 parent a8bad2a commit 9d3c7b0
Show file tree
Hide file tree
Showing 29 changed files with 133 additions and 510 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

- Relay dependencies upgraded to version `11.0.0-rc.0`, see: https://github.com/facebook/relay/releases/tag/v11.0.0-rc.0
- Packages `@adeira/relay-runtime` and `@adeira/relay-utils` merged to this package. Everything should work without any extra changes (except for updating the exports). Please, let us know in case we missed something.

# 3.0.1
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@
"@adeira/signed-source": "^2.0.0",
"@babel/register": "^7.13.8",
"@babel/runtime": "^7.13.9",
"babel-plugin-relay": "^10.1.3",
"babel-plugin-relay": "^11.0.0-rc.0",
"commander": "^7.1.0",
"is-ci": "^3.0.0",
"react-relay": "^10.1.3",
"relay-compiler": "^10.1.3",
"relay-config": "^10.1.3",
"relay-runtime": "^10.1.3"
"react-relay": "^11.0.0-rc.0",
"relay-compiler": "^11.0.0-rc.0",
"relay-config": "^11.0.0-rc.0",
"relay-runtime": "^11.0.0-rc.0"
},
"devDependencies": {
"@testing-library/react-hooks": "^5.1.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-test-renderer": "^17.0.1",
"relay-test-utils": "^10.1.3"
"relay-test-utils": "^11.0.0-rc.0"
},
"peerDependencies": {
"graphql": "^14.5.8",
Expand Down
4 changes: 2 additions & 2 deletions src/__flowtests__/DeclarativeMutationConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ module.exports = {
connectionInfo: [
{
key: 'FavoritesList_favorites',
// $FlowExpectedError[incompatible-call]: unsupported range behavior
rangeBehavior: 'unsupported',
// $FlowExpectedError[incompatible-call]: should be a string
rangeBehavior: -1,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import { useMutation, graphql, type Disposable } from '../../index';
import { useMutation, graphql, type Disposable } from '../index';

const mutation = graphql`
mutation useMutation {
Expand Down
30 changes: 17 additions & 13 deletions src/__tests__/publicExports.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,35 @@ import * as publicExports from '../index';

it('exports only what we want to export', () => {
// this is to make sure we are always exporting the subset we want to
expect(Object.keys(publicExports)).toMatchInlineSnapshot(`
expect(
Object.keys(publicExports).sort((a, b) => {
return a.localeCompare(b);
}),
).toMatchInlineSnapshot(`
Array [
"FetchResponseError",
"FetchTimeoutError",
"createEnvironment",
"createLocalEnvironment",
"createNetworkFetcher",
"getDataFromRequest",
"RelayDebugLogger",
"RelayEagerLogger",
"RelayLazyLogger",
"commitLocalUpdate",
"commitMutation",
"commitMutationAsync",
"ConnectionHandler",
"createEnvironment",
"createFragmentContainer",
"createLocalEnvironment",
"createNetworkFetcher",
"createPaginationContainer",
"createRefetchContainer",
"fetchQuery",
"FetchResponseError",
"FetchTimeoutError",
"getDataFromRequest",
"graphql",
"LocalQueryRenderer",
"QueryRenderer",
"requestSubscription",
"graphql",
"readInlineData",
"ConnectionHandler",
"RelayDebugLogger",
"RelayEagerLogger",
"RelayEnvironmentProvider",
"RelayLazyLogger",
"requestSubscription",
"useMutation",
"useRelayEnvironment",
]
Expand Down
2 changes: 1 addition & 1 deletion src/createRelayStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
type Options = {|
gcScheduler?: ?Scheduler,
operationLoader?: ?OperationLoader,
UNSTABLE_DO_NOT_USE_getDataID?: ?GetDataID,
getDataID?: ?GetDataID,
gcReleaseBufferSize?: ?number,
queryCacheExpirationTime?: ?number,
log?: ?LogFunction,
Expand Down
12 changes: 9 additions & 3 deletions src/createRequestHandler.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
// @flow

import { Observable, type CacheConfig, type Variables, type GraphQLResponse } from 'relay-runtime';
import {
Observable,
type CacheConfig,
type Variables,
type GraphQLResponse,
type UploadableMap,
} from 'relay-runtime';

import type { RequestNode, Uploadables } from './types.flow';
import type { RequestNode } from './types.flow';

/**
* A Sink is an object of methods provided by Observable during construction.
Expand All @@ -22,7 +28,7 @@ export default function createRequestHandler(
requestNode: RequestNode,
variables: Variables,
cacheConfig: CacheConfig,
uploadables: ?Uploadables,
uploadables: ?UploadableMap,
) => Observable<GraphQLResponse> {
return function handleRequest(requestNode, variables, cacheConfig, uploadables) {
return Observable.create((sink: Sink) => {
Expand Down
2 changes: 1 addition & 1 deletion src/fetchQuery.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import { fetchQuery as relayFetchQuery, type Environment } from 'react-relay';
import { fetchQuery_DEPRECATED as relayFetchQuery, type Environment } from 'react-relay';
import type { OperationType, GraphQLTaggedNode } from 'relay-runtime';

// https://relay.dev/docs/en/fetch-query
Expand Down
6 changes: 3 additions & 3 deletions src/fetchers/createNetworkFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import fetchWithRetries from '@adeira/fetch';
import { invariant } from '@adeira/js';
import type { Variables } from 'relay-runtime';
import type { Variables, UploadableMap } from 'relay-runtime';

import { handleData, getRequestBody, getHeaders } from '../helpers';
import type { RequestNode, Uploadables } from '../types.flow';
import type { RequestNode } from '../types.flow';

type Headers = {
+[string]: string,
Expand All @@ -26,7 +26,7 @@ export default function createNetworkFetcher(
): (
request: RequestNode,
variables: Variables,
uploadables: ?Uploadables,
uploadables: ?UploadableMap,
) => Promise<$FlowFixMe | string> {
return async function fetch(request, variables, uploadables) {
const body = getRequestBody(request, variables, uploadables);
Expand Down
8 changes: 4 additions & 4 deletions src/helpers.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @flow strict-local

import type { Variables } from 'relay-runtime';
import type { Variables, UploadableMap } from 'relay-runtime';

import type { Uploadables, RequestNode } from './types.flow';
import type { RequestNode } from './types.flow';

export const isMutation = (request: RequestNode): boolean %checks => {
return request.operationKind === 'mutation';
Expand Down Expand Up @@ -59,7 +59,7 @@ function getRequestBodyWithoutUplodables(request, variables): string {
export function getRequestBody(
request: RequestNode,
variables: Variables,
uploadables: ?Uploadables,
uploadables: ?UploadableMap,
): string | FormData {
if (uploadables) {
return getRequestBodyWithUploadables(request, variables, uploadables);
Expand All @@ -68,7 +68,7 @@ export function getRequestBody(
}

export const getHeaders = (
uploadables: ?Uploadables,
uploadables: ?UploadableMap,
): {| +'Accept': string, +'Content-type'?: string |} => {
if (uploadables) {
return {
Expand Down
113 changes: 0 additions & 113 deletions src/hooks/__tests__/__generated__/useMutationTestMutation.graphql.js

This file was deleted.

This file was deleted.

Loading

0 comments on commit 9d3c7b0

Please sign in to comment.