Skip to content

Commit

Permalink
drop Relay prefix from ConnectionHandler and ConnectionInterface
Browse files Browse the repository at this point in the history
Summary:
These modules are already exported under these shorter names and this brings the
internal file names in sync with the publicly exported names.

Reviewed By: alunyov

Differential Revision: D19164010

fbshipit-source-id: 4e9817036b3fe4a1dba6dd5c5a69c50886518e00
  • Loading branch information
kassens authored and facebook-github-bot committed Dec 19, 2019
1 parent b421819 commit 5febecd
Show file tree
Hide file tree
Showing 16 changed files with 111 additions and 128 deletions.
Expand Up @@ -12,7 +12,7 @@

'use strict';

const RelayConnectionHandler = require('./connection/RelayConnectionHandler');
const ConnectionHandler = require('./connection/ConnectionHandler');

const invariant = require('invariant');

Expand All @@ -22,7 +22,7 @@ export type HandlerProvider = (name: string) => ?Handler;
function RelayDefaultHandlerProvider(handle: string): Handler {
switch (handle) {
case 'connection':
return RelayConnectionHandler;
return ConnectionHandler;
}
invariant(
false,
Expand Down
Expand Up @@ -12,7 +12,7 @@

'use strict';

const RelayConnectionInterface = require('./RelayConnectionInterface');
const ConnectionInterface = require('./ConnectionInterface');

const getRelayHandleKey = require('../../util/getRelayHandleKey');
const invariant = require('invariant');
Expand Down Expand Up @@ -63,7 +63,7 @@ function update(store: RecordSourceProxy, payload: HandleFieldPayload): void {
PAGE_INFO,
PAGE_INFO_TYPE,
START_CURSOR,
} = RelayConnectionInterface.get();
} = ConnectionInterface.get();

const serverConnection = record.getLinkedRecord(payload.fieldKey);
const serverPageInfo =
Expand Down Expand Up @@ -157,7 +157,7 @@ function update(store: RecordSourceProxy, payload: HandleFieldPayload): void {
} else {
warning(
false,
'RelayConnectionHandler: Unexpected after cursor `%s`, edges must ' +
'Relay: Unexpected after cursor `%s`, edges must ' +
'be fetched from the end of the list (`%s`).',
args.after,
clientPageInfo && clientPageInfo.getValue(END_CURSOR),
Expand All @@ -176,7 +176,7 @@ function update(store: RecordSourceProxy, payload: HandleFieldPayload): void {
} else {
warning(
false,
'RelayConnectionHandler: Unexpected before cursor `%s`, edges must ' +
'Relay: Unexpected before cursor `%s`, edges must ' +
'be fetched from the beginning of the list (`%s`).',
args.before,
clientPageInfo && clientPageInfo.getValue(START_CURSOR),
Expand Down Expand Up @@ -254,7 +254,7 @@ function update(store: RecordSourceProxy, payload: HandleFieldPayload): void {
* ```
* store => {
* const user = store.get('<id>');
* const friends = RelayConnectionHandler.getConnection(user, 'FriendsFragment_friends');
* const friends = ConnectionHandler.getConnection(user, 'FriendsFragment_friends');
* // Access fields on the connection:
* const edges = friends.getLinkedRecords('edges');
* }
Expand Down Expand Up @@ -301,9 +301,9 @@ function getConnection(
* ```
* store => {
* const user = store.get('<id>');
* const friends = RelayConnectionHandler.getConnection(user, 'FriendsFragment_friends');
* const friends = ConnectionHandler.getConnection(user, 'FriendsFragment_friends');
* const edge = store.create('<edge-id>', 'FriendsEdge');
* RelayConnectionHandler.insertEdgeAfter(friends, edge);
* ConnectionHandler.insertEdgeAfter(friends, edge);
* }
* ```
*/
Expand All @@ -312,7 +312,7 @@ function insertEdgeAfter(
newEdge: RecordProxy,
cursor?: ?string,
): void {
const {CURSOR, EDGES} = RelayConnectionInterface.get();
const {CURSOR, EDGES} = ConnectionInterface.get();

const edges = record.getLinkedRecords(EDGES);
if (!edges) {
Expand Down Expand Up @@ -355,7 +355,7 @@ function createEdge(
node: RecordProxy,
edgeType: string,
): RecordProxy {
const {NODE} = RelayConnectionInterface.get();
const {NODE} = ConnectionInterface.get();

// An index-based client ID could easily conflict (unless it was
// auto-incrementing, but there is nowhere to the store the id)
Expand Down Expand Up @@ -400,9 +400,9 @@ function createEdge(
* ```
* store => {
* const user = store.get('<id>');
* const friends = RelayConnectionHandler.getConnection(user, 'FriendsFragment_friends');
* const friends = ConnectionHandler.getConnection(user, 'FriendsFragment_friends');
* const edge = store.create('<edge-id>', 'FriendsEdge');
* RelayConnectionHandler.insertEdgeBefore(friends, edge);
* ConnectionHandler.insertEdgeBefore(friends, edge);
* }
* ```
*/
Expand All @@ -411,7 +411,7 @@ function insertEdgeBefore(
newEdge: RecordProxy,
cursor?: ?string,
): void {
const {CURSOR, EDGES} = RelayConnectionInterface.get();
const {CURSOR, EDGES} = ConnectionInterface.get();

const edges = record.getLinkedRecords(EDGES);
if (!edges) {
Expand Down Expand Up @@ -448,7 +448,7 @@ function insertEdgeBefore(
* Remove any edges whose `node.id` matches the given id.
*/
function deleteNode(record: RecordProxy, nodeID: DataID): void {
const {EDGES, NODE} = RelayConnectionInterface.get();
const {EDGES, NODE} = ConnectionInterface.get();

const edges = record.getLinkedRecords(EDGES);
if (!edges) {
Expand Down Expand Up @@ -492,12 +492,12 @@ function buildConnectionEdge(
if (edge == null) {
return edge;
}
const {EDGES} = RelayConnectionInterface.get();
const {EDGES} = ConnectionInterface.get();

const edgeIndex = connection.getValue(NEXT_EDGE_INDEX);
invariant(
typeof edgeIndex === 'number',
'RelayConnectionHandler: Expected %s to be a number, got `%s`.',
'ConnectionHandler: Expected %s to be a number, got `%s`.',
NEXT_EDGE_INDEX,
edgeIndex,
);
Expand All @@ -519,7 +519,7 @@ function mergeEdges(
targetEdges: Array<?RecordProxy>,
nodeIDs: Set<mixed>,
): void {
const {NODE} = RelayConnectionInterface.get();
const {NODE} = ConnectionInterface.get();

for (let ii = 0; ii < sourceEdges.length; ii++) {
const edge = sourceEdges[ii];
Expand Down
Expand Up @@ -70,7 +70,7 @@ let config: ConnectionConfig = {
*
* Defines logic relevant to the informal "Connection" GraphQL interface.
*/
const RelayConnectionInterface = {
const ConnectionInterface = {
inject(newConfig: ConnectionConfig) {
config = newConfig;
},
Expand All @@ -89,4 +89,4 @@ const RelayConnectionInterface = {
},
};

module.exports = RelayConnectionInterface;
module.exports = ConnectionInterface;

0 comments on commit 5febecd

Please sign in to comment.