4 |
5 | {%= o.htmlWebpackPlugin.options.title %}
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | ---
2 | parser: babel-eslint
3 |
4 | extends:
5 | - ./node_modules/fbjs-scripts/eslint/.eslintrc
6 |
7 | plugins:
8 | - react
9 |
10 | rules:
11 | react/jsx-uses-react: 2
12 |
13 | globals:
14 | $Enum: true
15 | $FixMe: true
16 | $FlowFixMe: true
17 | $FlowIssue: true
18 | Iterator: true
19 | IteratorResult: true
20 | ReactClass: true
21 | ReactElement: true
22 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/queryWithoutFields.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`query { viewer }`;
4 |
5 | Output:
6 | var Relay = require('react-relay');
7 | var x = (function () {
8 | return {
9 | fieldName: 'viewer',
10 | kind: 'Query',
11 | metadata: {},
12 | name: 'QueryWithoutFields',
13 | type: 'Viewer'
14 | };
15 | })();
16 |
--------------------------------------------------------------------------------
/src/__mocks__/Relay.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require('RelayPublic');
13 |
--------------------------------------------------------------------------------
/src/tools/__mocks__/configureForRelayOSS.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | global.__RELAYOSS__ = true;
13 |
--------------------------------------------------------------------------------
/src/__mocks__/RelayPublic.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayPublic');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/RelayQL.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayQL');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/buildRQL.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('buildRQL');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/RelayQuery.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayQuery');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/fromGraphQL.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('fromGraphQL');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/toGraphQL.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('toGraphQL');
13 |
--------------------------------------------------------------------------------
/src/store/__mocks__/RelayStore.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayStore');
13 |
--------------------------------------------------------------------------------
/src/tools/__mocks__/RelayError.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayError');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/QueryBuilder.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('QueryBuilder');
13 |
--------------------------------------------------------------------------------
/website/core/SiteData.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule SiteData
10 | */
11 |
12 | module.exports = {
13 | version: '0.6.1'
14 | };
15 |
--------------------------------------------------------------------------------
/src/container/__mocks__/RelayPropTypes.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayPropTypes');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/callsFromGraphQL.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('callsFromGraphQL');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/callsToGraphQL.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('callsToGraphQL');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/createRelayQuery.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('createRelayQuery');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/fromGraphQLQuery.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('fromGraphQLQuery');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/stableStringify.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('stableStringify');
13 |
--------------------------------------------------------------------------------
/src/route/__mocks__/RelayMetaRoute.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayMetaRoute');
13 |
--------------------------------------------------------------------------------
/src/store/__mocks__/RelayQueryWriter.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayQueryWriter');
13 |
--------------------------------------------------------------------------------
/src/store/__mocks__/RelayRecordState.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayRecordState');
13 |
--------------------------------------------------------------------------------
/src/store/__mocks__/RelayRecordStore.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayRecordStore');
13 |
--------------------------------------------------------------------------------
/src/store/__mocks__/RelayStoreData.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayStoreData');
13 |
--------------------------------------------------------------------------------
/src/tools/__mocks__/RelayDeprecated.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayDeprecated');
13 |
--------------------------------------------------------------------------------
/src/traversal/__mocks__/sortTypeFirst.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('sortTypeFirst');
13 |
--------------------------------------------------------------------------------
/src/container/__mocks__/isReactComponent.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('isReactComponent');
13 |
--------------------------------------------------------------------------------
/src/container/__mocks__/isRelayContainer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('isRelayContainer');
13 |
--------------------------------------------------------------------------------
/src/mutation/__mocks__/RelayMutationType.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayMutationType');
13 |
--------------------------------------------------------------------------------
/src/network/__mocks__/RelayNetworkLayer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayNetworkLayer');
13 |
--------------------------------------------------------------------------------
/src/network/__mocks__/RelayQueryRequest.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayQueryRequest');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/RelayQueryVisitor.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayQueryVisitor');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/RelayRouteFragment.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayRouteFragment');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/forEachRootCallArg.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('forEachRootCallArg');
13 |
--------------------------------------------------------------------------------
/src/store/__mocks__/RelayChangeTracker.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayChangeTracker');
13 |
--------------------------------------------------------------------------------
/src/tools/__mocks__/RelayTaskScheduler.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayTaskScheduler');
13 |
--------------------------------------------------------------------------------
/src/traversal/__mocks__/filterRelayQuery.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('filterRelayQuery');
13 |
--------------------------------------------------------------------------------
/src/mutation/__mocks__/RelayMutationQueue.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayMutationQueue');
13 |
--------------------------------------------------------------------------------
/src/network/__mocks__/RelayMutationRequest.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayMutationRequest');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/RelayQueryTransform.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayQueryTransform');
13 |
--------------------------------------------------------------------------------
/src/store/__mocks__/RelayDiskCacheReader.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayDiskCacheReader');
13 |
--------------------------------------------------------------------------------
/src/store/__mocks__/RelayGarbageCollector.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayGarbageCollector');
13 |
--------------------------------------------------------------------------------
/src/store/__mocks__/RelayMutationTracker.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayMutationTracker');
13 |
--------------------------------------------------------------------------------
/src/store/__mocks__/RelayRecordStatusMap.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayRecordStatusMap');
13 |
--------------------------------------------------------------------------------
/src/store/__mocks__/filterExclusiveKeys.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('filterExclusiveKeys');
13 |
--------------------------------------------------------------------------------
/src/tools/__mocks__/RelayMetricsRecorder.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayMetricsRecorder');
13 |
--------------------------------------------------------------------------------
/src/traversal/__mocks__/flattenRelayQuery.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('flattenRelayQuery');
13 |
--------------------------------------------------------------------------------
/src/traversal/__mocks__/printRelayOSSQuery.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('printRelayOSSQuery');
13 |
--------------------------------------------------------------------------------
/src/__forks__/traversal/__mocks__/printRelayQuery.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('printRelayQuery');
13 |
--------------------------------------------------------------------------------
/src/interface/__mocks__/RelayOSSNodeInterface.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayOSSNodeInterface');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/RelayFragmentReference.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayFragmentReference');
13 |
--------------------------------------------------------------------------------
/src/query/__mocks__/RelayRefQueryDescriptor.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayRefQueryDescriptor');
13 |
--------------------------------------------------------------------------------
/src/__forks__/container/__mocks__/RelayContainerProxy.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayContainerProxy');
13 |
--------------------------------------------------------------------------------
/src/__forks__/interface/__mocks__/RelayNodeInterface.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayNodeInterface');
13 |
--------------------------------------------------------------------------------
/src/container/__mocks__/RelayOSSContainerProxy.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayOSSContainerProxy');
13 |
--------------------------------------------------------------------------------
/src/legacy/store/__mocks__/generateForceIndex.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | */
10 |
11 | 'use strict';
12 |
13 | module.exports = require.requireActual('generateForceIndex');
14 |
--------------------------------------------------------------------------------
/src/query/__mocks__/serializeRelayQueryCall.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('serializeRelayQueryCall');
13 |
--------------------------------------------------------------------------------
/src/store/__mocks__/RelayQueryResultObservable.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayQueryResultObservable');
13 |
--------------------------------------------------------------------------------
/src/traversal/__mocks__/flattenSplitRelayQueries.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('flattenSplitRelayQueries');
13 |
--------------------------------------------------------------------------------
/src/traversal/__mocks__/writeRelayUpdatePayload.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('writeRelayUpdatePayload');
13 |
--------------------------------------------------------------------------------
/src/legacy/mutation/__mocks__/GraphQLMutatorConstants.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('GraphQLMutatorConstants');
13 |
--------------------------------------------------------------------------------
/src/legacy/store/__mocks__/generateClientEdgeID.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | */
10 |
11 | 'use strict';
12 |
13 | module.exports = require.requireActual('generateClientEdgeID');
14 |
--------------------------------------------------------------------------------
/src/query/__mocks__/getConcreteFragmentHash.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | */
10 |
11 | 'use strict';
12 |
13 | module.exports = require.requireActual('getConcreteFragmentHash');
14 |
--------------------------------------------------------------------------------
/src/traversal/__mocks__/containsRelayQueryRootCall.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('containsRelayQueryRootCall');
13 |
--------------------------------------------------------------------------------
/src/traversal/__mocks__/transformRelayQueryPayload.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('transformRelayQueryPayload');
13 |
--------------------------------------------------------------------------------
/src/__forks__/interface/__mocks__/RelayConnectionInterface.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayConnectionInterface');
13 |
--------------------------------------------------------------------------------
/src/interface/__mocks__/RelayOSSConnectionInterface.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayOSSConnectionInterface');
13 |
--------------------------------------------------------------------------------
/src/legacy/store/__mocks__/GraphQLMutatorConstants.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | */
10 |
11 | 'use strict';
12 |
13 | module.exports = require.requireActual('GraphQLMutatorConstants');
14 |
--------------------------------------------------------------------------------
/src/tools/__mocks__/isCompatibleRelayFragmentType.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('isCompatibleRelayFragmentType');
13 |
--------------------------------------------------------------------------------
/src/__forks__/container/__mocks__/prepareRelayContainerProps.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('prepareRelayContainerProps');
13 |
--------------------------------------------------------------------------------
/src/network-layer/default/__mocks__/RelayDefaultNetworkLayer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = require.requireActual('RelayDefaultNetworkLayer');
13 |
--------------------------------------------------------------------------------
/src/__forks__/traversal/printRelayQuery.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule printRelayQuery
10 | */
11 |
12 | 'use strict';
13 |
14 | module.exports = require('printRelayOSSQuery');
15 |
--------------------------------------------------------------------------------
/src/legacy/store/__mocks__/recycleNodesInto.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | jest.dontMock('recycleNodesInto');
13 |
14 | module.exports = require('recycleNodesInto');
15 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/queryWithBadDirective.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | query {
5 | node(id: 123) @bad(if: $foo) {
6 | id
7 | }
8 | }
9 | `;
10 |
11 | Output:
12 | var Relay = require('react-relay');
13 | var x = (function () {
14 | throw new Error('GraphQL validation/transform error ``You supplied a directive named `bad`, but no such directive exists.`` in file `queryWithBadDirective.fixture`.');
15 | })();
16 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/queryWithBadDirectiveArgs.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | query {
5 | node(id: 123) @if(bad: $foo) {
6 | id
7 | }
8 | }
9 | `;
10 |
11 | Output:
12 | var Relay = require('react-relay');
13 | var x = (function () {
14 | throw new Error('GraphQL validation/transform error ``You supplied a directive named `if`, but no such directive exists.`` in file `queryWithBadDirectiveArgs.fixture`.');
15 | })();
16 |
--------------------------------------------------------------------------------
/src/__forks__/interface/RelayNodeInterface.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule RelayNodeInterface
10 | */
11 |
12 | 'use strict';
13 |
14 | module.exports = require('RelayOSSNodeInterface');
15 |
--------------------------------------------------------------------------------
/website/publish.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | # Start in website/ even if run from root directory
6 | cd "$(dirname "$0")"
7 |
8 | cd ../../relay-gh-pages
9 | # git checkout -- .
10 | # git clean -dfx
11 | # git fetch
12 | # git rebase
13 | rm -Rf *
14 | cd ../relay/website
15 | node server/generate.js
16 | cp -R build/relay/* ../../relay-gh-pages/
17 | rm -Rf build/
18 | cd ../../relay-gh-pages
19 | # git add --all
20 | # git commit -m "update website"
21 | # git push
22 | # cd ../relay/website
23 |
--------------------------------------------------------------------------------
/src/__forks__/container/RelayContainerProxy.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule RelayContainerProxy
10 | */
11 |
12 | 'use strict';
13 |
14 | module.exports = require('RelayOSSContainerProxy');
15 |
--------------------------------------------------------------------------------
/src/traversal/__mocks__/diffRelayQuery.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = jest.genMockFunction().mockImplementation(
13 | require.requireActual('diffRelayQuery')
14 | );
15 |
--------------------------------------------------------------------------------
/src/traversal/__mocks__/subtractRelayQuery.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = jest.genMockFunction().mockImplementation(
13 | require.requireActual('subtractRelayQuery')
14 | );
15 |
--------------------------------------------------------------------------------
/src/__forks__/interface/RelayConnectionInterface.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule RelayConnectionInterface
10 | */
11 |
12 | 'use strict';
13 |
14 | module.exports = require('RelayOSSConnectionInterface');
15 |
--------------------------------------------------------------------------------
/src/store/__mocks__/validateRelayReadQuery.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | var validateRelayReadQuery = require.requireActual('validateRelayReadQuery');
13 | module.exports = validateRelayReadQuery;
14 |
--------------------------------------------------------------------------------
/src/traversal/__mocks__/checkRelayQueryData.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = jest.genMockFunction().mockImplementation(
13 | require.requireActual('checkRelayQueryData')
14 | );
15 |
--------------------------------------------------------------------------------
/src/traversal/__mocks__/findRelayQueryLeaves.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = jest.genMockFunction().mockImplementation(
13 | require.requireActual('findRelayQueryLeaves')
14 | );
15 |
--------------------------------------------------------------------------------
/src/traversal/__mocks__/intersectRelayQuery.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = jest.genMockFunction().mockImplementation(
13 | require.requireActual('intersectRelayQuery')
14 | );
15 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/README.md:
--------------------------------------------------------------------------------
1 | # babel-relay-plugin
2 |
3 | ## Installation
4 |
5 | ```sh
6 | cd relay/scripts/babel-relay-plugin
7 | npm install
8 | ```
9 |
10 | ## Tests
11 |
12 | ```sh
13 | npm test
14 | ```
15 |
16 | ## Usage
17 |
18 | ```js
19 | var plugin = getBabelRelayPlugin(parsedSchemaJSON.data);
20 |
21 | babel.transform(source, {
22 | plugins: [plugin],
23 | ...
24 | });
25 | ```
26 |
27 | ## License
28 |
29 | Relay is [BSD licensed](./LICENSE). We also provide an additional [patent grant](./PATENTS).
30 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/nonExistantMutation.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | mutation {
5 | fakeMutation(input: $input) {
6 | actor {
7 | profilePicture,
8 | },
9 | },
10 | }
11 | `;
12 |
13 | Output:
14 | var Relay = require('react-relay');
15 | var x = (function () {
16 | throw new Error('GraphQL validation/transform error ``Cannot query field "fakeMutation" on "Mutation".`` in file `nonExistantMutation.fixture`.');
17 | })();
18 |
--------------------------------------------------------------------------------
/src/__forks__/container/prepareRelayContainerProps.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule prepareRelayContainerProps
10 | */
11 |
12 | 'use strict';
13 |
14 | module.exports = require('prepareRelayOSSContainerProps');
15 |
--------------------------------------------------------------------------------
/src/legacy/store/__mocks__/generateRQLFieldAlias.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = jest.genMockFunction().mockImplementation(
13 | require.requireActual('generateRQLFieldAlias')
14 | );
15 |
--------------------------------------------------------------------------------
/src/traversal/__mocks__/writeRelayQueryPayload.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = jest.genMockFunction().mockImplementation(
13 | require.requireActual('writeRelayQueryPayload')
14 | );
15 |
--------------------------------------------------------------------------------
/src/traversal/__mocks__/inferRelayFieldsFromData.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = jest.genMockFunction().mockImplementation(
13 | require.requireActual('inferRelayFieldsFromData')
14 | );
15 |
--------------------------------------------------------------------------------
/src/traversal/__mocks__/splitDeferredRelayQueries.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | module.exports = jest.genMockFunction().mockImplementation(
13 | require.requireActual('splitDeferredRelayQueries')
14 | );
15 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/inlineFragmentWithoutType.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | /*
4 | TODO: Upgrade to graphql@0.4.7 and uncomment this.
5 |
6 | var x = Relay.QL`
7 | fragment on Node {
8 | ... {
9 | id,
10 | },
11 | }
12 | `;
13 | */
14 |
15 | Output:
16 | var Relay = require('react-relay');
17 | /*
18 | TODO: Upgrade to graphql@0.4.7 and uncomment this.
19 |
20 | var x = Relay.QL`
21 | fragment on Node {
22 | ... {
23 | id,
24 | },
25 | }
26 | `;
27 | */
28 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/mutationWithExtraArgs.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | mutation MutationNameHere {
5 | actorSubscribe(input: $input, extra: $extra) {
6 | ${reference},
7 | },
8 | }
9 | `;
10 |
11 | Output:
12 | var Relay = require('react-relay');
13 | var x = (function () {
14 | throw new Error('GraphQL validation/transform error ``Unknown argument "extra" on field "actorSubscribe" of type "Mutation".`` in file `mutationWithExtraArgs.fixture`.');
15 | })();
16 |
--------------------------------------------------------------------------------
/src/container/__mocks__/getRelayQueries.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | var getRelayQueries = require.requireActual('getRelayQueries');
13 |
14 | module.exports = jest.genMockFunction().mockImplementation(getRelayQueries);
15 |
--------------------------------------------------------------------------------
/src/store/__mocks__/readRelayQueryData.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | var readRelayQueryData = require.requireActual('readRelayQueryData');
13 | module.exports = jest.genMockFunction().mockImplementation(readRelayQueryData);
14 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/mutationBadSchemaMissingArgs.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | mutation {
5 | mutationMissingArg,
6 | }
7 | `;
8 |
9 | Output:
10 | var Relay = require('react-relay');
11 | var x = (function () {
12 | throw new Error('GraphQL validation/transform error ``Your schema defines a mutation field `mutationMissingArg` that takes 0 arguments, but mutation fields must have exactly one argument named `input`.`` in file `mutationBadSchemaMissingArgs.fixture`.');
13 | })();
14 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/mutationBadSchemaWrongArgs.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | mutation {
5 | mutationWrongArgs,
6 | }
7 | `;
8 |
9 | Output:
10 | var Relay = require('react-relay');
11 | var x = (function () {
12 | throw new Error('GraphQL validation/transform error ``Your schema defines a mutation field `mutationWrongArgs` that takes an argument named `foo`, but mutation fields must have exactly one argument named `input`.`` in file `mutationBadSchemaWrongArgs.fixture`.');
13 | })();
14 |
--------------------------------------------------------------------------------
/src/legacy/store/__mocks__/generateClientID.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | var count = 1;
13 |
14 | var generateClientID = jest.genMockFunction().mockImplementation(
15 | () => { return 'client:' + count++; }
16 | );
17 |
18 | module.exports = generateClientID;
19 |
--------------------------------------------------------------------------------
/src/query/__mocks__/RelayQueryPath.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | var RelayQueryPath = require.requireActual('RelayQueryPath');
13 |
14 | RelayQueryPath.fromJSON = jest.genMockFunction().mockImplementation(
15 | RelayQueryPath.fromJSON
16 | );
17 |
18 | module.exports = RelayQueryPath;
19 |
--------------------------------------------------------------------------------
/src/store/RelayStore.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule RelayStore
10 | * @flow
11 | * @typechecks
12 | */
13 |
14 | 'use strict';
15 |
16 | const RelayContext = require('RelayContext');
17 | const RelayStoreData = require('RelayStoreData');
18 |
19 | module.exports = new RelayContext(RelayStoreData.getDefaultInstance());
20 |
--------------------------------------------------------------------------------
/website/core/H2.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule H2
10 | */
11 |
12 | var React = require('React');
13 | var Header = require('Header');
14 |
15 | var H2 = React.createClass({
16 | render: function() {
17 | return {this.props.children}
18 | }
19 | });
20 |
21 | module.exports = H2;
22 |
--------------------------------------------------------------------------------
/examples/star-wars/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Relay • Star Wars
7 |
8 |
9 |
10 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/website/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "repository": "facebook/relay",
3 | "license": "BSD-3-Clause",
4 | "scripts": {
5 | "start": "node server/server.js"
6 | },
7 | "dependencies": {
8 | "compression": "1.2.2",
9 | "connect": "3.3.3",
10 | "errorhandler": "1.3.0",
11 | "fs-extra": "0.23.1",
12 | "glob": "*",
13 | "mkdirp": "*",
14 | "morgan": "1.5.0",
15 | "object-assign": "^2.0.0",
16 | "optimist": "0.6.0",
17 | "react": "~0.12.0",
18 | "react-page-middleware": "git://github.com/facebook/react-page-middleware.git",
19 | "request": "*",
20 | "serve-static": "1.7.1",
21 | "spec-md": "0.3.7"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/examples/relay-treasurehunt/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Relay • Treasure Hunt
7 |
8 |
9 |
10 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/legacy/store/__mocks__/GraphQLFragmentPointer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | var GraphQLFragmentPointer = require.requireActual('GraphQLFragmentPointer');
13 |
14 | GraphQLFragmentPointer.createForRoot =
15 | jest.genMockFunction().mockImplementation(
16 | GraphQLFragmentPointer.createForRoot
17 | );
18 |
19 | module.exports = GraphQLFragmentPointer;
20 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/nonRootNodeField.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('Relay');
3 | var fragment = Relay.QL`
4 | fragment on InvalidType {
5 | node(id: 123) {
6 | ... on User {
7 | name
8 | }
9 | }
10 | }
11 | `;
12 |
13 | Output:
14 | var Relay = require('Relay');
15 | var fragment = (function () {
16 | throw new Error('GraphQL validation/transform error ``You defined a `node(id: Int)` field on type `InvalidType`, but Relay requires the `node` field to be defined on the root type. See the Object Identification Guide: \nhttp://facebook.github.io/relay/docs/graphql-object-identification.html`` in file `nonRootNodeField.fixture`.');
17 | })();
18 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/lib/find.js:
--------------------------------------------------------------------------------
1 | // @generated
2 | /**
3 | * Copyright 2013-2015, Facebook, Inc.
4 | * All rights reserved.
5 | *
6 | * This source code is licensed under the BSD-style license found in the
7 | * LICENSE file in the root directory of this source tree. An additional grant
8 | * of patent rights can be found in the PATENTS file in the same directory.
9 | *
10 | *
11 | * @fullSyntaxTransform
12 | */
13 |
14 | 'use strict';
15 |
16 | function find(array, predicate, context) {
17 | for (var ii = 0; ii < array.length; ii++) {
18 | if (predicate.call(context, array[ii], ii, array)) {
19 | return array[ii];
20 | }
21 | }
22 | return undefined;
23 | }
24 |
25 | module.exports = find;
--------------------------------------------------------------------------------
/src/store/__mocks__/RelayRecord.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | const RelayRecord = require.requireActual('RelayRecord');
13 |
14 | Object.keys(RelayRecord).forEach(name => {
15 | const method = RelayRecord[name];
16 | if (typeof method === 'function') {
17 | RelayRecord[name] = jest.genMockFunction().mockImplementation(method);
18 | }
19 | });
20 |
21 | module.exports = RelayRecord;
22 |
--------------------------------------------------------------------------------
/src/legacy/store/DliteFetchModeConstants.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule DliteFetchModeConstants
10 | * @typechecks
11 | */
12 |
13 | 'use strict';
14 |
15 | const keyMirror = require('keyMirror');
16 |
17 | var DliteFetchModeConstants = keyMirror({
18 | FETCH_MODE_CLIENT: null,
19 | FETCH_MODE_PRELOAD: null,
20 | FETCH_MODE_REFETCH: null,
21 | });
22 |
23 | module.exports = DliteFetchModeConstants;
24 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/connectionWithNodesField.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | query {
5 | node(id: 123) {
6 | ... on User {
7 | friends(first: 3) {
8 | nodes {
9 | id,
10 | },
11 | },
12 | },
13 | },
14 | }
15 | `;
16 |
17 | Output:
18 | var Relay = require('react-relay');
19 | var x = (function () {
20 | throw new Error('GraphQL validation/transform error ``You supplied a field named `nodes` on a connection named `friends`, but pagination is not supported on connections without using `edges`. Use `friends{edges{node{...}}}` instead.`` in file `connectionWithNodesField.fixture`.');
21 | })();
22 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/invariant.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @flow
10 | * @fullSyntaxTransform
11 | */
12 |
13 | 'use strict';
14 |
15 | const util = require('util');
16 |
17 | function invariant(
18 | condition: mixed,
19 | format: string,
20 | ...args: Array
21 | ): void {
22 | if (!condition) {
23 | throw new Error(util.format(format, ...args));
24 | }
25 | }
26 |
27 | module.exports = invariant;
28 |
--------------------------------------------------------------------------------
/src/mutation/RelayMutationType.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule RelayMutationType
10 | * @typechecks
11 | * @flow
12 | */
13 |
14 | 'use strict';
15 |
16 | var RelayMutationType = {
17 | FIELDS_CHANGE: 'FIELDS_CHANGE',
18 | NODE_DELETE: 'NODE_DELETE',
19 | RANGE_ADD: 'RANGE_ADD',
20 | RANGE_DELETE: 'RANGE_DELETE',
21 | REQUIRED_CHILDREN: 'REQUIRED_CHILDREN',
22 | };
23 |
24 | module.exports = RelayMutationType;
25 |
--------------------------------------------------------------------------------
/examples/star-wars-angular/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Relay • Star Wars
7 |
8 |
9 |
10 |
11 |
12 |
13 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/connectionWithoutArgs.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | query {
5 | node(id: 123) {
6 | ... on User {
7 | friends {
8 | edges {
9 | node {
10 | id,
11 | },
12 | },
13 | },
14 | },
15 | },
16 | }
17 | `;
18 |
19 | Output:
20 | var Relay = require('react-relay');
21 | var x = (function () {
22 | throw new Error('GraphQL validation/transform error ``You supplied the `edges` field on a connection named `friends`, but you did not supply an argument necessary to do so. Use either the `find`, `first`, or `last` argument.`` in file `connectionWithoutArgs.fixture`.');
23 | })();
24 |
--------------------------------------------------------------------------------
/src/container/isRelayContainer.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule isRelayContainer
10 | * @flow
11 | * @typechecks
12 | */
13 |
14 | 'use strict';
15 |
16 | function isRelayContainer(component: any): boolean {
17 | return !!(
18 | component &&
19 | component.getFragmentNames &&
20 | component.getFragment &&
21 | component.hasFragment &&
22 | component.hasVariable
23 | );
24 | }
25 |
26 | module.exports = isRelayContainer;
27 |
--------------------------------------------------------------------------------
/examples/todo/public/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Relay • TodoMVC
7 |
8 |
9 |
10 |
11 |
12 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/src/traversal/sortTypeFirst.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule sortTypeFirst
10 | * @typechecks
11 | * @flow
12 | */
13 |
14 | 'use strict';
15 |
16 | var TYPE = '__type__';
17 |
18 | function sortTypeFirst(a: string, b: string): number {
19 | if (a === b) {
20 | return 0;
21 | }
22 | if (a === TYPE) {
23 | return -1;
24 | }
25 | if (b === TYPE) {
26 | return 1;
27 | }
28 | return 0;
29 | }
30 |
31 | module.exports = sortTypeFirst;
32 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/fragment.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`fragment on Node { id }`;
4 |
5 | Output:
6 | var Relay = require('react-relay');
7 | var x = (function () {
8 | return {
9 | children: [{
10 | fieldName: 'id',
11 | kind: 'Field',
12 | metadata: {
13 | isRequisite: true
14 | },
15 | type: 'String'
16 | }, {
17 | fieldName: '__typename',
18 | kind: 'Field',
19 | metadata: {
20 | isGenerated: true,
21 | isRequisite: true
22 | },
23 | type: 'String'
24 | }],
25 | kind: 'Fragment',
26 | metadata: {
27 | isAbstract: true
28 | },
29 | name: 'Fragment',
30 | type: 'Node'
31 | };
32 | })();
33 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/connectionWithAfterLastArgs.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | query {
5 | node(id: 123) {
6 | ... on User {
7 | friends(last: 3, after: "foo") {
8 | edges {
9 | node {
10 | id,
11 | },
12 | },
13 | },
14 | },
15 | },
16 | }
17 | `;
18 |
19 | Output:
20 | var Relay = require('react-relay');
21 | var x = (function () {
22 | throw new Error('GraphQL validation/transform error ``Connection arguments `friends(after: , last: )` are not supported. Use `(last: )`, `(before: , last: )`, or `(after: , first: )`.`` in file `connectionWithAfterLastArgs.fixture`.');
23 | })();
24 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/metadataRequisite.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`fragment on Node { id }`;
4 |
5 | Output:
6 | var Relay = require('react-relay');
7 | var x = (function () {
8 | return {
9 | children: [{
10 | fieldName: 'id',
11 | kind: 'Field',
12 | metadata: {
13 | isRequisite: true
14 | },
15 | type: 'String'
16 | }, {
17 | fieldName: '__typename',
18 | kind: 'Field',
19 | metadata: {
20 | isGenerated: true,
21 | isRequisite: true
22 | },
23 | type: 'String'
24 | }],
25 | kind: 'Fragment',
26 | metadata: {
27 | isAbstract: true
28 | },
29 | name: 'MetadataRequisite',
30 | type: 'Node'
31 | };
32 | })();
33 |
--------------------------------------------------------------------------------
/website/core/center.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule center
10 | */
11 |
12 | var React = require('React');
13 |
14 | var assign = require('object-assign')
15 |
16 | var center = React.createClass({
17 | render: function() {
18 | var {style, ...props} = this.props;
19 | style = assign({}, style, {textAlign: 'center'});
20 |
21 | return (
22 |
{this.props.children}
23 | );
24 | }
25 | });
26 |
27 | module.exports = center;
28 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/connectionWithBeforeFirstArgs.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | query {
5 | node(id: 123) {
6 | ... on User {
7 | friends(first: 3, before: "foo") {
8 | edges {
9 | node {
10 | id,
11 | },
12 | },
13 | },
14 | },
15 | },
16 | }
17 | `;
18 |
19 | Output:
20 | var Relay = require('react-relay');
21 | var x = (function () {
22 | throw new Error('GraphQL validation/transform error ``Connection arguments `friends(before: , first: )` are not supported. Use `(first: )`, `(after: , first: )`, or `(before: , last: )`.`` in file `connectionWithBeforeFirstArgs.fixture`.');
23 | })();
24 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/introspectionQueryForSchema.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var foo = Relay.QL`
3 | query IntrospectionQueryForSchema {
4 | __schema {
5 | types {
6 | name,
7 | },
8 | },
9 | }
10 | `;
11 |
12 | Output:
13 | var foo = (function () {
14 | return {
15 | children: [{
16 | children: [{
17 | fieldName: "name",
18 | kind: "Field",
19 | metadata: {},
20 | type: "String"
21 | }],
22 | fieldName: "types",
23 | kind: "Field",
24 | metadata: {
25 | isPlural: true
26 | },
27 | type: "__Type"
28 | }],
29 | fieldName: "__schema",
30 | kind: "Query",
31 | metadata: {},
32 | name: "IntrospectionQueryForSchema",
33 | type: "__Schema"
34 | };
35 | })();
36 |
--------------------------------------------------------------------------------
/src/legacy/store/generateForceIndex.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule generateForceIndex
10 | * @flow
11 | * @typechecks
12 | */
13 |
14 | 'use strict';
15 |
16 | var _index = 1;
17 |
18 | /**
19 | * Generate a new force index used to write GraphQL data in the store. A new
20 | * force index can be used to overwrite previous ranges.
21 | *
22 | * @internal
23 | */
24 | function generateForceIndex(): number {
25 | return _index++;
26 | }
27 |
28 | module.exports = generateForceIndex;
29 |
--------------------------------------------------------------------------------
/examples/todo/js/queries/ViewerQueries.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This file provided by Facebook is for non-commercial testing and evaluation
3 | * purposes only. Facebook reserves all rights not expressly granted.
4 | *
5 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8 | * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
9 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 | */
12 |
13 | import Relay from 'react-relay';
14 |
15 | export default {
16 | viewer: () => Relay.QL`query { viewer }`,
17 | };
18 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/fragmentWithName.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`fragment FragmentNameHere on Node { id }`;
4 |
5 | Output:
6 | var Relay = require('react-relay');
7 | var x = (function () {
8 | return {
9 | children: [{
10 | fieldName: 'id',
11 | kind: 'Field',
12 | metadata: {
13 | isRequisite: true
14 | },
15 | type: 'String'
16 | }, {
17 | fieldName: '__typename',
18 | kind: 'Field',
19 | metadata: {
20 | isGenerated: true,
21 | isRequisite: true
22 | },
23 | type: 'String'
24 | }],
25 | kind: 'Fragment',
26 | metadata: {
27 | isAbstract: true
28 | },
29 | name: 'FragmentNameHere',
30 | type: 'Node'
31 | };
32 | })();
33 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/find.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @flow
10 | * @fullSyntaxTransform
11 | */
12 |
13 | 'use strict';
14 |
15 | function find(
16 | array: Array,
17 | predicate: (element: T, index: number, array: Array) => boolean,
18 | context: any
19 | ): ?T {
20 | for (var ii = 0; ii < array.length; ii++) {
21 | if (predicate.call(context, array[ii], ii, array)) {
22 | return array[ii];
23 | }
24 | }
25 | return undefined;
26 | }
27 |
28 | module.exports = find;
29 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/introspectionQueryForType.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var foo = Relay.QL`
3 | query IntrospectionQueryForType {
4 | __type(name: "Root") {
5 | name,
6 | },
7 | }
8 | `;
9 |
10 | Output:
11 | var foo = (function () {
12 | return {
13 | calls: [{
14 | kind: "Call",
15 | metadata: {},
16 | name: "name",
17 | value: {
18 | kind: "CallValue",
19 | callValue: "Root"
20 | }
21 | }],
22 | children: [{
23 | fieldName: "name",
24 | kind: "Field",
25 | metadata: {},
26 | type: "String"
27 | }],
28 | fieldName: "__type",
29 | kind: "Query",
30 | metadata: {
31 | identifyingArgName: "name"
32 | },
33 | name: "IntrospectionQueryForType",
34 | type: "__Type"
35 | };
36 | })();
37 |
--------------------------------------------------------------------------------
/src/.flowconfig:
--------------------------------------------------------------------------------
1 | [ignore]
2 | .*/__tests__/.*
3 | .*/node_modules/graphql/.*
4 | .*/react/node_modules/.*
5 | .*/react-static-container/node_modules/.*
6 |
7 | [include]
8 | ../node_modules/fbjs/flow/include
9 | ../node_modules/fbjs/node_modules/promise
10 |
11 | [libs]
12 | ../node_modules/fbjs/flow/lib
13 |
14 | [options]
15 | module.system=haste
16 | munge_underscores=true
17 |
18 | suppress_type=$FlowIssue
19 | suppress_type=$FlowFixMe
20 | suppress_type=$FixMe
21 |
22 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-0]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*\\)?)\\)
23 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-0]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*\\)?)\\)? #[0-9]+
24 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
25 |
26 | [version]
27 | 0.20.1
28 |
--------------------------------------------------------------------------------
/src/legacy/store/generateClientEdgeID.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule generateClientEdgeID
10 | * @flow
11 | * @typechecks
12 | */
13 |
14 | 'use strict';
15 |
16 | /**
17 | * Generate an edge client id for edges on connections based on the range it
18 | * belongs to and the node it contains.
19 | *
20 | * @internal
21 | */
22 | function generateClientEdgeID(rangeID: string, nodeID: string): string {
23 | return 'client:' + rangeID + ':' + nodeID;
24 | }
25 |
26 | module.exports = generateClientEdgeID;
27 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/fragmentDirectives.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`fragment on Node @relay(plural: true) { id }`;
4 |
5 | Output:
6 | var Relay = require('react-relay');
7 | var x = (function () {
8 | return {
9 | children: [{
10 | fieldName: 'id',
11 | kind: 'Field',
12 | metadata: {
13 | isRequisite: true
14 | },
15 | type: 'String'
16 | }, {
17 | fieldName: '__typename',
18 | kind: 'Field',
19 | metadata: {
20 | isGenerated: true,
21 | isRequisite: true
22 | },
23 | type: 'String'
24 | }],
25 | kind: 'Fragment',
26 | metadata: {
27 | plural: true,
28 | isAbstract: true
29 | },
30 | name: 'FragmentDirectives',
31 | type: 'Node'
32 | };
33 | })();
34 |
--------------------------------------------------------------------------------
/examples/star-wars/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "start": "babel-node ./server.js",
5 | "update-schema": "babel-node ./scripts/updateSchema.js",
6 | "preinstall": "cd ../.. && npm install --ignore-scripts && cd scripts/babel-relay-plugin && npm install --ignore-scripts"
7 | },
8 | "dependencies": {
9 | "babel": "5.8.23",
10 | "babel-core": "^5.8.25",
11 | "babel-loader": "5.3.2",
12 | "babel-relay-plugin": "file:../../scripts/babel-relay-plugin/",
13 | "classnames": "^2.1.3",
14 | "express": "^4.13.1",
15 | "express-graphql": "^0.4.0",
16 | "graphql": "0.4.13",
17 | "graphql-relay": "^0.3.3",
18 | "react": "^0.14.0",
19 | "react-dom": "^0.14.0",
20 | "react-relay": "file:../../",
21 | "webpack": "^1.10.5",
22 | "webpack-dev-server": "^1.10.1"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/connectionWithoutArgsWithInlineFragment.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | query {
5 | node(id: 123) {
6 | ... on User {
7 | friends {
8 | ... on UserConnection {
9 | edges {
10 | node {
11 | id,
12 | },
13 | },
14 | },
15 | },
16 | },
17 | },
18 | }
19 | `;
20 |
21 | Output:
22 | var Relay = require('react-relay');
23 | var x = (function () {
24 | throw new Error('GraphQL validation/transform error ``You supplied the `edges` field on a connection named `friends`, but you did not supply an argument necessary to do so. Use either the `find`, `first`, or `last` argument.`` in file `connectionWithoutArgsWithInlineFragment.fixture`.');
25 | })();
26 |
--------------------------------------------------------------------------------
/examples/todo/build/babelRelayPlugin.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This file provided by Facebook is for non-commercial testing and evaluation
3 | * purposes only. Facebook reserves all rights not expressly granted.
4 | *
5 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8 | * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
9 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 | */
12 |
13 | var getBabelRelayPlugin = require('babel-relay-plugin');
14 | var schema = require('../data/schema.json');
15 |
16 | module.exports = getBabelRelayPlugin(schema.data);
17 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/lib/invariant.js:
--------------------------------------------------------------------------------
1 | // @generated
2 | /**
3 | * Copyright 2013-2015, Facebook, Inc.
4 | * All rights reserved.
5 | *
6 | * This source code is licensed under the BSD-style license found in the
7 | * LICENSE file in the root directory of this source tree. An additional grant
8 | * of patent rights can be found in the PATENTS file in the same directory.
9 | *
10 | *
11 | * @fullSyntaxTransform
12 | */
13 |
14 | 'use strict';
15 |
16 | var util = require('util');
17 |
18 | function invariant(condition, format) {
19 | if (!condition) {
20 | for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
21 | args[_key - 2] = arguments[_key];
22 | }
23 |
24 | throw new Error(util.format.apply(util, [format].concat(args)));
25 | }
26 | }
27 |
28 | module.exports = invariant;
--------------------------------------------------------------------------------
/src/container/isReactComponent.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule isReactComponent
10 | * @typechecks
11 | * @flow
12 | */
13 |
14 | 'use strict';
15 |
16 | /**
17 | * @internal
18 | *
19 | * Helper for checking if this is a React Component
20 | * created with React.Component or React.createClass().
21 | */
22 | function isReactComponent(component: mixed): boolean {
23 | return !!(
24 | component &&
25 | component.prototype &&
26 | component.prototype.isReactComponent
27 | );
28 | }
29 |
30 | module.exports = isReactComponent;
31 |
--------------------------------------------------------------------------------
/examples/relay-treasurehunt/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "start": "babel-node ./server.js",
5 | "update-schema": "babel-node ./scripts/updateSchema.js",
6 | "preinstall": "cd ../.. && npm install --ignore-scripts && cd scripts/babel-relay-plugin && npm install --ignore-scripts"
7 | },
8 | "dependencies": {
9 | "babel": "5.8.23",
10 | "babel-core": "^5.8.25",
11 | "babel-loader": "5.3.2",
12 | "babel-relay-plugin": "file:../../scripts/babel-relay-plugin/",
13 | "classnames": "^2.1.3",
14 | "express": "^4.13.1",
15 | "express-graphql": "^0.4.0",
16 | "graphql": "0.4.13",
17 | "graphql-relay": "^0.3.3",
18 | "react": "^0.14.0",
19 | "react-dom": "^0.14.0",
20 | "react-relay": "file:../../",
21 | "webpack": "^1.10.5",
22 | "webpack-dev-server": "^1.10.1"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/examples/star-wars/build/babelRelayPlugin.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This file provided by Facebook is for non-commercial testing and evaluation
3 | * purposes only. Facebook reserves all rights not expressly granted.
4 | *
5 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8 | * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
9 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 | */
12 |
13 | var getBabelRelayPlugin = require('babel-relay-plugin');
14 | var schema = require('../data/schema.json');
15 |
16 | module.exports = getBabelRelayPlugin(schema.data);
17 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/metadataNonFindable.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | query {
5 | viewer {
6 | pendingPosts {
7 | count,
8 | },
9 | },
10 | }
11 | `;
12 |
13 | Output:
14 | var Relay = require('react-relay');
15 | var x = (function () {
16 | return {
17 | children: [{
18 | children: [{
19 | fieldName: 'count',
20 | kind: 'Field',
21 | metadata: {},
22 | type: 'Int'
23 | }],
24 | fieldName: 'pendingPosts',
25 | kind: 'Field',
26 | metadata: {
27 | isConnection: true
28 | },
29 | type: 'PendingPostsConnection'
30 | }],
31 | fieldName: 'viewer',
32 | kind: 'Query',
33 | metadata: {},
34 | name: 'MetadataNonFindable',
35 | type: 'Viewer'
36 | };
37 | })();
38 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/unionWithTypename.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var foo = Relay.QL`
3 | query UnionWithTypename {
4 | media(id: 123) {
5 | __typename,
6 | },
7 | }
8 | `;
9 |
10 | Output:
11 | var foo = (function () {
12 | return {
13 | calls: [{
14 | kind: "Call",
15 | metadata: {},
16 | name: "id",
17 | value: {
18 | kind: "CallValue",
19 | callValue: 123
20 | }
21 | }],
22 | children: [{
23 | fieldName: "__typename",
24 | kind: "Field",
25 | metadata: {
26 | isRequisite: true
27 | },
28 | type: "String"
29 | }],
30 | fieldName: "media",
31 | kind: "Query",
32 | metadata: {
33 | isAbstract: true,
34 | identifyingArgName: "id"
35 | },
36 | name: "UnionWithTypename",
37 | type: "Media"
38 | };
39 | })();
40 |
--------------------------------------------------------------------------------
/src/route/__mocks__/RelayRoute.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @typechecks
10 | */
11 |
12 | 'use strict';
13 |
14 | var RelayRoute = require.requireActual('RelayRoute');
15 |
16 | RelayRoute.genMock = jest.genMockFunction().mockImplementation(() => {
17 | class MockRoute extends RelayRoute {}
18 | MockRoute.routeName = 'MockRoute';
19 | MockRoute.path = '/jest';
20 | return MockRoute;
21 | });
22 |
23 | RelayRoute.genMockInstance = jest.genMockFunction().mockImplementation(
24 | () => new (RelayRoute.genMock())()
25 | );
26 |
27 | module.exports = RelayRoute;
28 |
--------------------------------------------------------------------------------
/examples/relay-treasurehunt/build/babelRelayPlugin.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This file provided by Facebook is for non-commercial testing and evaluation
3 | * purposes only. Facebook reserves all rights not expressly granted.
4 | *
5 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8 | * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
9 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 | */
12 |
13 | var getBabelRelayPlugin = require('babel-relay-plugin');
14 | var schema = require('../data/schema.json');
15 |
16 | module.exports = getBabelRelayPlugin(schema.data);
17 |
--------------------------------------------------------------------------------
/examples/star-wars-angular/build/babelRelayPlugin.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This file provided by Facebook is for non-commercial testing and evaluation
3 | * purposes only. Facebook reserves all rights not expressly granted.
4 | *
5 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8 | * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
9 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 | */
12 |
13 | var getBabelRelayPlugin = require('babel-relay-plugin');
14 | var schema = require('../data/schema.json');
15 |
16 | module.exports = getBabelRelayPlugin(schema.data);
17 |
--------------------------------------------------------------------------------
/src/legacy/store/__mocks__/GraphQLStoreRangeUtils.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | */
10 |
11 | 'use strict';
12 |
13 | const GraphQLStoreRangeUtils = require.requireActual('GraphQLStoreRangeUtils');
14 |
15 | Object.keys(GraphQLStoreRangeUtils.prototype).forEach(name => {
16 | const property = GraphQLStoreRangeUtils.prototype[name];
17 | if (typeof property === 'function') {
18 | GraphQLStoreRangeUtils.prototype[name] =
19 | jest.genMockFunction().mockImplementation(property);
20 | }
21 | });
22 |
23 | module.exports = require.requireActual('GraphQLStoreRangeUtils');
24 |
--------------------------------------------------------------------------------
/website/core/unindent.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule unindent
10 | */
11 |
12 | // Remove the indentation introduced by JSX
13 | function unindent(code) {
14 | var lines = code.split('\n');
15 | if (lines[0] === '') {
16 | lines.shift();
17 | }
18 | if (lines.length <= 1) {
19 | return code;
20 | }
21 |
22 | var indent = lines[0].match(/^\s*/)[0];
23 | for (var i = 0; i < lines.length; ++i) {
24 | lines[i] = lines[i].replace(new RegExp('^' + indent), '');
25 | }
26 | return lines.join('\n');
27 | }
28 |
29 | module.exports = unindent;
30 |
--------------------------------------------------------------------------------
/website/src/relay/img/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/fragmentWithReference.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`fragment on Node { ${reference} }`;
4 |
5 | Output:
6 | var Relay = require('react-relay');
7 | var x = (function (RQL_0) {
8 | return {
9 | children: [{
10 | fieldName: 'id',
11 | kind: 'Field',
12 | metadata: {
13 | isGenerated: true,
14 | isRequisite: true
15 | },
16 | type: 'String'
17 | }, {
18 | fieldName: '__typename',
19 | kind: 'Field',
20 | metadata: {
21 | isGenerated: true,
22 | isRequisite: true
23 | },
24 | type: 'String'
25 | }, Relay.QL.__frag(RQL_0)],
26 | kind: 'Fragment',
27 | metadata: {
28 | isAbstract: true
29 | },
30 | name: 'FragmentWithReference',
31 | type: 'Node'
32 | };
33 | })(reference);
34 |
--------------------------------------------------------------------------------
/website-prototyping-tools/logo.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/fragmentWithoutCommas.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | fragment on Node {
5 | ${reference}
6 | id
7 | }
8 | `;
9 |
10 | Output:
11 | var Relay = require('react-relay');
12 | var x = (function (RQL_0) {
13 | return {
14 | children: [{
15 | fieldName: 'id',
16 | kind: 'Field',
17 | metadata: {
18 | isRequisite: true
19 | },
20 | type: 'String'
21 | }, {
22 | fieldName: '__typename',
23 | kind: 'Field',
24 | metadata: {
25 | isGenerated: true,
26 | isRequisite: true
27 | },
28 | type: 'String'
29 | }, Relay.QL.__frag(RQL_0)],
30 | kind: 'Fragment',
31 | metadata: {
32 | isAbstract: true
33 | },
34 | name: 'FragmentWithoutCommas',
35 | type: 'Node'
36 | };
37 | })(reference);
38 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/connectionWithAfterLastArgsWithInlineFragment.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | query {
5 | node(id: 123) {
6 | ... on User {
7 | friends(last: 3, after: "foo") {
8 | ... on UserConnection {
9 | edges {
10 | node {
11 | id,
12 | },
13 | },
14 | },
15 | },
16 | },
17 | },
18 | }
19 | `;
20 |
21 | Output:
22 | var Relay = require('react-relay');
23 | var x = (function () {
24 | throw new Error('GraphQL validation/transform error ``Connection arguments `friends(after: , last: )` are not supported. Use `(last: )`, `(before: , last: )`, or `(after: , first: )`.`` in file `connectionWithAfterLastArgsWithInlineFragment.fixture`.');
25 | })();
26 |
--------------------------------------------------------------------------------
/src/query-config/__mocks__/RelayQueryConfig.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @typechecks
10 | */
11 |
12 | 'use strict';
13 |
14 | var RelayQueryConfig = require.requireActual('RelayQueryConfig');
15 |
16 | RelayQueryConfig.genMock = jest.genMockFunction().mockImplementation(() => {
17 | class MockQueryConfig extends RelayQueryConfig {}
18 | MockQueryConfig.routeName = 'MockQueryConfig';
19 | return MockQueryConfig;
20 | });
21 |
22 | RelayQueryConfig.genMockInstance = jest.genMockFunction().mockImplementation(
23 | () => new (RelayQueryConfig.genMock())()
24 | );
25 |
26 | module.exports = RelayQueryConfig;
27 |
--------------------------------------------------------------------------------
/examples/relay-treasurehunt/js/routes/AppHomeRoute.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This file provided by Facebook is for non-commercial testing and evaluation
3 | * purposes only. Facebook reserves all rights not expressly granted.
4 | *
5 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8 | * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
9 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 | */
12 |
13 | import Relay from 'react-relay';
14 |
15 | export default class extends Relay.Route {
16 | static queries = {
17 | game: () => Relay.QL`query { game }`,
18 | };
19 | static routeName = 'AppHomeRoute';
20 | }
21 |
--------------------------------------------------------------------------------
/src/legacy/store/generateClientID.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule generateClientID
10 | * @typechecks
11 | */
12 |
13 | 'use strict';
14 |
15 | const crc32 = require('crc32');
16 | const performanceNow = require('performanceNow');
17 |
18 | var _clientID = 1;
19 | var _prefix = 'client:' + crc32('' + performanceNow());
20 |
21 | /**
22 | * Generate a unique clientID for GraphQL data objects that do not already have
23 | * an ID or their ID = null
24 | *
25 | * @internal
26 | */
27 | function generateClientID() {
28 | return _prefix + _clientID++;
29 | }
30 |
31 | module.exports = generateClientID;
32 |
--------------------------------------------------------------------------------
/src/legacy/store/__mocks__/GraphQLStoreChangeEmitter.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | var GraphQLStoreChangeEmitter = jest.genMockFromModule('GraphQLStoreChangeEmitter');
13 |
14 | GraphQLStoreChangeEmitter.mockImplementation(function() {
15 | this.addListenerForIDs.mock.remove = [];
16 | this.addListenerForIDs.mockImplementation(() => {
17 | var returnValue = {remove: jest.genMockFunction()};
18 | this.addListenerForIDs.mock.remove.push(
19 | returnValue.remove
20 | );
21 | return returnValue;
22 | });
23 |
24 | return this;
25 | });
26 |
27 | module.exports = GraphQLStoreChangeEmitter;
28 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/mutationWithoutArgs.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | mutation {
5 | actorSubscribe,
6 | }
7 | `;
8 |
9 | Output:
10 | var Relay = require('react-relay');
11 | var x = (function () {
12 | return {
13 | calls: [{
14 | kind: 'Call',
15 | metadata: {},
16 | name: 'actorSubscribe',
17 | value: {
18 | kind: 'CallVariable',
19 | callVariableName: 'input'
20 | }
21 | }],
22 | children: [{
23 | fieldName: 'clientMutationId',
24 | kind: 'Field',
25 | metadata: {
26 | isGenerated: true,
27 | isRequisite: true
28 | },
29 | type: 'String'
30 | }],
31 | kind: 'Mutation',
32 | metadata: {
33 | inputType: 'ActorSubscribeInput'
34 | },
35 | name: 'MutationWithoutArgs',
36 | responseType: 'ActorSubscribeResponsePayload'
37 | };
38 | })();
39 |
--------------------------------------------------------------------------------
/src/__forks__/Relay.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule Relay
10 | * @typechecks
11 | * @flow
12 | */
13 |
14 | 'use strict';
15 |
16 | var RelayDefaultNetworkLayer = require('RelayDefaultNetworkLayer');
17 | var RelayPublic = require('RelayPublic');
18 |
19 | // By default, assume that GraphQL is served at `/graphql` on the same domain.
20 | // $FlowFixMe(>=0.16.0)
21 | RelayPublic.injectNetworkLayer(new RelayDefaultNetworkLayer('/graphql'));
22 |
23 | module.exports = {
24 | ...RelayPublic,
25 | // Expose the default network layer to allow convenient re-configuration.
26 | DefaultNetworkLayer: RelayDefaultNetworkLayer,
27 | };
28 |
--------------------------------------------------------------------------------
/website/server/buildGraphQLSpec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | var exec = require('child_process').execFileSync;
11 | var fs = require('fs-extra');
12 | var glob = require('glob');
13 |
14 | module.exports = function(targetDir) {
15 | fs.copySync('node_modules/spec-md/css', targetDir + '/relay/graphql');
16 | glob.sync('graphql/*.md').forEach(function(file) {
17 | var html = exec('./node_modules/.bin/spec-md', [file]);
18 | var outFilename = (
19 | targetDir + '/relay/graphql/' +
20 | path.basename(file, '.md').toLowerCase() +
21 | '.htm'
22 | );
23 | fs.writeFileSync(outFilename, html.toString());
24 | });
25 | }
26 |
--------------------------------------------------------------------------------
/examples/star-wars/js/routes/StarWarsAppHomeRoute.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This file provided by Facebook is for non-commercial testing and evaluation
3 | * purposes only. Facebook reserves all rights not expressly granted.
4 | *
5 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8 | * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
9 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 | */
12 |
13 | import Relay from 'react-relay';
14 |
15 | export default class extends Relay.Route {
16 | static queries = {
17 | factions: () => Relay.QL`query { factions(names: $factionNames) }`,
18 | };
19 | static routeName = 'StarWarsAppHomeRoute';
20 | }
21 |
--------------------------------------------------------------------------------
/examples/star-wars-angular/js/routes/StarWarsAppHomeRoute.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This file provided by Facebook is for non-commercial testing and evaluation
3 | * purposes only. Facebook reserves all rights not expressly granted.
4 | *
5 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8 | * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
9 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 | */
12 |
13 | import Relay from 'generic-relay';
14 |
15 | export default class extends Relay.Route {
16 | static queries = {
17 | factions: () => Relay.QL`query { factions(names: $factionNames) }`,
18 | };
19 | static routeName = 'StarWarsAppHomeRoute';
20 | }
21 |
--------------------------------------------------------------------------------
/examples/star-wars-angular/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "start": "babel-node ./server.js",
5 | "update-schema": "babel-node ./scripts/updateSchema.js",
6 | "preinstall": "cd ../.. && npm install --ignore-scripts && cd scripts/babel-relay-plugin && npm install --ignore-scripts"
7 | },
8 | "dependencies": {
9 | "angular": "^1.4.8",
10 | "babel": "5.8.23",
11 | "babel-core": "^5.8.25",
12 | "babel-eslint": "^4.1.6",
13 | "babel-loader": "5.3.2",
14 | "babel-relay-plugin": "file:../../scripts/babel-relay-plugin/",
15 | "classnames": "^2.1.3",
16 | "eslint-plugin-react": "^3.15.0",
17 | "express": "^4.13.1",
18 | "express-graphql": "^0.4.0",
19 | "generic-relay": "file:../../",
20 | "graphql": "0.4.13",
21 | "graphql-relay": "^0.3.3",
22 | "react": "^0.14.0",
23 | "react-dom": "^0.14.0",
24 | "webpack": "^1.10.5",
25 | "webpack-dev-server": "^1.10.1"
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/argsSubstitution.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var foo = Relay.QL`
3 | query Args {
4 | node(id: ${userID}) {
5 | id,
6 | },
7 | }
8 | `;
9 |
10 | Output:
11 | var foo = (function (RQL_0) {
12 | return {
13 | calls: [{
14 | kind: "Call",
15 | metadata: {},
16 | name: "id",
17 | value: Relay.QL.__var(RQL_0)
18 | }],
19 | children: [{
20 | fieldName: "id",
21 | kind: "Field",
22 | metadata: {
23 | isRequisite: true
24 | },
25 | type: "String"
26 | }, {
27 | fieldName: "__typename",
28 | kind: "Field",
29 | metadata: {
30 | isGenerated: true,
31 | isRequisite: true
32 | },
33 | type: "String"
34 | }],
35 | fieldName: "node",
36 | kind: "Query",
37 | metadata: {
38 | isAbstract: true,
39 | identifyingArgName: "id"
40 | },
41 | name: "Args",
42 | type: "Node"
43 | };
44 | })(userID);
45 |
--------------------------------------------------------------------------------
/website-prototyping-tools/babelRelayPlaygroundPlugin.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | export default function({Plugin, types: t}) {
11 | return new Plugin('babel-relay-playground', {
12 | visitor: {
13 | CallExpression(node) {
14 | var callee = this.get('callee');
15 | if (
16 | callee.matchesPattern('React.render') ||
17 | callee.matchesPattern('ReactDOM.render')
18 | ) {
19 | // We found a ReactDOM.render(...) type call.
20 | // Pluck the ReactElement from the call, and export it instead.
21 | return t.exportDefaultDeclaration(node.arguments[0]);
22 | }
23 | },
24 | },
25 | });
26 | }
27 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/queryWithObjectArg.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('Relay');
3 | var q = Relay.QL`
4 | query {
5 | search(query: $query) {
6 | title,
7 | },
8 | }
9 | `;
10 |
11 | Output:
12 | var Relay = require('Relay');
13 | var q = (function () {
14 | return {
15 | calls: [{
16 | kind: 'Call',
17 | metadata: {
18 | type: '[SearchInput!]'
19 | },
20 | name: 'query',
21 | value: {
22 | kind: 'CallVariable',
23 | callVariableName: 'query'
24 | }
25 | }],
26 | children: [{
27 | fieldName: 'title',
28 | kind: 'Field',
29 | metadata: {},
30 | type: 'String'
31 | }],
32 | fieldName: 'search',
33 | kind: 'Query',
34 | metadata: {
35 | isPlural: true,
36 | identifyingArgName: 'query',
37 | identifyingArgType: '[SearchInput!]'
38 | },
39 | name: 'QueryWithObjectArg',
40 | type: 'SearchResult'
41 | };
42 | })();
43 |
--------------------------------------------------------------------------------
/src/traversal/__tests__/sortTypeFirst-test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @emails oncall+relay
10 | */
11 |
12 | 'use strict';
13 |
14 | const sortTypeFirst = require('sortTypeFirst');
15 |
16 | describe('sortTypeFirst', () => {
17 | it('considers `__type__` to be the smallest', () => {
18 | expect(sortTypeFirst('__type__', '_')).toBe(-1);
19 | expect(sortTypeFirst('_', '__type__')).toBe(1);
20 | expect(sortTypeFirst('__type__', '__type__')).toBe(0);
21 | });
22 |
23 | it('does not compare non-`__type__` strings', () => {
24 | expect(sortTypeFirst('a', 'b')).toBe(0);
25 | expect(sortTypeFirst('b', 'a')).toBe(0);
26 | expect(sortTypeFirst('a', 'a')).toBe(0);
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/website/layout/PageLayout.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule PageLayout
10 | */
11 |
12 | var React = require('React');
13 | var Site = require('Site');
14 | var Marked = require('Marked');
15 |
16 | var support = React.createClass({
17 | render: function() {
18 | var metadata = this.props.metadata;
19 | var content = this.props.children;
20 | return (
21 |
22 |
23 |
24 | {content}
25 |
26 |
27 |
28 | );
29 | }
30 | });
31 |
32 | module.exports = support;
33 |
--------------------------------------------------------------------------------
/examples/todo/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "scripts": {
4 | "start": "babel-node ./server.js",
5 | "update-schema": "babel-node ./scripts/updateSchema.js",
6 | "preinstall": "cd ../.. && npm install --ignore-scripts && cd scripts/babel-relay-plugin && npm install --ignore-scripts"
7 | },
8 | "dependencies": {
9 | "babel": "5.8.23",
10 | "babel-core": "^5.8.25",
11 | "babel-loader": "5.3.2",
12 | "babel-relay-plugin": "file:../../scripts/babel-relay-plugin/",
13 | "classnames": "^2.1.5",
14 | "express": "^4.13.3",
15 | "express-graphql": "^0.4.0",
16 | "graphql": "0.4.13",
17 | "graphql-relay": "^0.3.3",
18 | "history": "1.13.0",
19 | "react": "^0.14.0",
20 | "react-dom": "^0.14.0",
21 | "react-relay": "file:../../",
22 | "react-router": "^1.0.0",
23 | "react-router-relay": "^0.8.0",
24 | "todomvc-app-css": "^2.0.3",
25 | "todomvc-common": "^1.0.2",
26 | "webpack": "^1.12.2",
27 | "webpack-dev-server": "^1.12.0"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/subscription.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | subscription {
5 | likeStory(input: $input) {
6 | ${reference},
7 | },
8 | }
9 | `;
10 |
11 | Output:
12 | var Relay = require('react-relay');
13 | var x = (function (RQL_0) {
14 | return {
15 | calls: [{
16 | kind: 'Call',
17 | metadata: {},
18 | name: 'likeStory',
19 | value: {
20 | kind: 'CallVariable',
21 | callVariableName: 'input'
22 | }
23 | }],
24 | children: [{
25 | fieldName: 'clientSubscriptionId',
26 | kind: 'Field',
27 | metadata: {
28 | isGenerated: true,
29 | isRequisite: true
30 | },
31 | type: 'String'
32 | }, Relay.QL.__frag(RQL_0)],
33 | kind: 'Subscription',
34 | metadata: {
35 | inputType: 'LikeStorySubscriptionInput'
36 | },
37 | name: 'Subscription',
38 | responseType: 'LikeStorySubscriptionPayload'
39 | };
40 | })(reference);
41 |
--------------------------------------------------------------------------------
/website-prototyping-tools/evalSchema.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | /* eslint-disable no-unused-vars, no-eval */
11 |
12 | import babel from 'babel-core/browser';
13 |
14 | var GraphQL = require('graphql');
15 | var GraphQLRelay = require('graphql-relay');
16 |
17 | export default function(source) {
18 | // Make these modules available to the schema author through a require shim.
19 | function require(path) {
20 | switch (path) {
21 | case 'graphql': return GraphQL;
22 | case 'graphql-relay': return GraphQLRelay;
23 |
24 | default: throw new Error(`Cannot find module "${path}"`);
25 | }
26 | }
27 | var {code} = babel.transform(source, {code: true, ast: false});
28 | return eval(code);
29 | }
30 |
--------------------------------------------------------------------------------
/src/route/RelayMetaRoute.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule RelayMetaRoute
10 | * @flow
11 | * @typechecks
12 | */
13 |
14 | 'use strict';
15 |
16 | /**
17 | * Meta route based on the real route; provides access to the route name in
18 | * queries.
19 | */
20 | class RelayMetaRoute {
21 | name: string;
22 |
23 | constructor(name: string) {
24 | Object.defineProperty(this, 'name', {
25 | enumerable: true,
26 | value: name,
27 | writable: false,
28 | });
29 | }
30 |
31 | static get(name: string) {
32 | return cache[name] || (cache[name] = new RelayMetaRoute(name));
33 | }
34 |
35 | }
36 |
37 | var cache: {[key: string]: RelayMetaRoute} = {};
38 |
39 | module.exports = RelayMetaRoute;
40 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/mutationWithName.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | mutation MutationNameHere {
5 | actorSubscribe(input: $input) {
6 | ${reference},
7 | },
8 | }
9 | `;
10 |
11 | Output:
12 | var Relay = require('react-relay');
13 | var x = (function (RQL_0) {
14 | return {
15 | calls: [{
16 | kind: 'Call',
17 | metadata: {},
18 | name: 'actorSubscribe',
19 | value: {
20 | kind: 'CallVariable',
21 | callVariableName: 'input'
22 | }
23 | }],
24 | children: [{
25 | fieldName: 'clientMutationId',
26 | kind: 'Field',
27 | metadata: {
28 | isGenerated: true,
29 | isRequisite: true
30 | },
31 | type: 'String'
32 | }, Relay.QL.__frag(RQL_0)],
33 | kind: 'Mutation',
34 | metadata: {
35 | inputType: 'ActorSubscribeInput'
36 | },
37 | name: 'MutationNameHere',
38 | responseType: 'ActorSubscribeResponsePayload'
39 | };
40 | })(reference);
41 |
--------------------------------------------------------------------------------
/docs/GraphQL-FurtherReading.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: graphql-further-reading
3 | title: Further Reading
4 | layout: docs
5 | category: GraphQL
6 | permalink: docs/graphql-further-reading.html
7 | indent: true
8 | next: api-reference-relay
9 | ---
10 |
11 | This concludes the overview of the GraphQL Relay Specifications. For the
12 | detailed requirements of a Relay-compliant GraphQL server, a more formal
13 | description of the [Relay cursor connection](../graphql/connections.htm) model,
14 | the [Relay global object identification](../graphql/objectidentification.htm)
15 | model, and the [Relay input object mutation](../graphql/mutations.htm) are all
16 | available.
17 |
18 | To see code implementing the specification, the
19 | [GraphQL.js Relay library](https://github.com/graphql/graphql-relay-js) provides
20 | helper functions for creating nodes, connections, and mutations; that
21 | repository's [`__tests__`](https://github.com/graphql/graphql-relay-js/tree/master/src/__tests__)
22 | folder contains an implementation of the above example as integration tests for
23 | the repository.
24 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/scripts/build-lib:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | var babel = require('babel');
4 | var fs = require('fs');
5 | var glob = require('glob');
6 | var mkdirp = require('mkdirp');
7 | var path = require('path');
8 | var rimraf = require('rimraf');
9 |
10 | var root = path.resolve(__dirname, '..');
11 | var lib = path.join(root, 'lib');
12 | var src = path.join(root, 'src');
13 |
14 | // Blow away prior build artifacts.
15 | rimraf.sync(lib);
16 |
17 | // Get the files to transform
18 | var files = glob.sync('**/*.js', {
19 | cwd: src,
20 | ignore: '**/__tests__/*'}
21 | );
22 | files.forEach((file) => {
23 | // Make sure file is fully resolved
24 | var srcFile = path.resolve(src, file);
25 | var libFile = path.resolve(lib, file);
26 |
27 | // Make sure the full path the destination file exists so we can write to it
28 | mkdirp.sync(path.dirname(libFile));
29 | var code = babel.transformFileSync(srcFile).code;
30 |
31 | // Prepend @generated annotation
32 | code = '// @generated\n' + code;
33 | fs.writeFile(libFile, code, 'utf8');
34 | });
35 |
--------------------------------------------------------------------------------
/examples/relay-treasurehunt/js/app.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This file provided by Facebook is for non-commercial testing and evaluation
3 | * purposes only. Facebook reserves all rights not expressly granted.
4 | *
5 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8 | * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
9 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 | */
12 |
13 | import 'babel/polyfill';
14 | import App from './components/App';
15 | import AppHomeRoute from './routes/AppHomeRoute';
16 | import React from 'react';
17 | import ReactDOM from 'react-dom';
18 | import Relay from 'react-relay';
19 |
20 | ReactDOM.render(
21 | ,
25 | document.getElementById('root')
26 | );
27 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/lib/GraphQLRelayDirective.js:
--------------------------------------------------------------------------------
1 | // @generated
2 | /**
3 | * Copyright 2013-2015, Facebook, Inc.
4 | * All rights reserved.
5 | *
6 | * This source code is licensed under the BSD-style license found in the
7 | * LICENSE file in the root directory of this source tree. An additional grant
8 | * of patent rights can be found in the PATENTS file in the same directory.
9 | *
10 | *
11 | * @fullSyntaxTransform
12 | */
13 |
14 | 'use strict';
15 |
16 | var types = require('./GraphQL').type;
17 |
18 | module.exports = {
19 | name: 'relay',
20 | description: 'The @relay directive on fragments.',
21 | args: [{
22 | name: 'pattern',
23 | description: 'Marks a fragment as intended for pattern matching (as ' + 'opposed to fetching).',
24 | type: types.GraphQLBoolean,
25 | defaultValue: null
26 | }, {
27 | name: 'plural',
28 | description: 'Marks a fragment as being backed by a GraphQLList',
29 | type: types.GraphQLBoolean,
30 | defaultValue: null
31 | }],
32 | onOperation: false,
33 | onFragment: true,
34 | onField: false
35 | };
--------------------------------------------------------------------------------
/src/query/createRelayQuery.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule createRelayQuery
10 | * @typechecks
11 | * @flow
12 | */
13 |
14 | 'use strict';
15 |
16 | const RelayMetaRoute = require('RelayMetaRoute');
17 | const RelayQuery = require('RelayQuery');
18 |
19 | const invariant = require('invariant');
20 |
21 | function createRelayQuery(
22 | node: Object,
23 | variables: {[key: string]: mixed}
24 | ): RelayQuery.Root {
25 | invariant(
26 | typeof variables === 'object' &&
27 | variables != null &&
28 | !Array.isArray(variables),
29 | 'Relay.Query: Expected `variables` to be an object.'
30 | );
31 | return RelayQuery.Root.create(
32 | node,
33 | RelayMetaRoute.get('$createRelayQuery'),
34 | variables
35 | );
36 | }
37 |
38 | module.exports = createRelayQuery;
39 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/argsInvalidValues.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var foo = Relay.QL`
3 | query Args {
4 | node(id: 123) {
5 | ... on User {
6 | friends(
7 | first: "10",
8 | orderby: Name,
9 | find: cursor1,
10 | isViewerFriend: "true",
11 | gender: "MALE",
12 | ) {
13 | edges {
14 | node {
15 | id,
16 | },
17 | },
18 | },
19 | },
20 | },
21 | }
22 | `;
23 |
24 | Output:
25 | var foo = (function () {
26 | throw new Error("GraphQL validation/transform error ``Argument \"first\" has invalid value \"10\".\nExpected type \"Int\", found \"10\". Argument \"orderby\" has invalid value Name.\nExpected type \"String\", found Name. Argument \"find\" has invalid value cursor1.\nExpected type \"String\", found cursor1. Argument \"isViewerFriend\" has invalid value \"true\".\nExpected type \"Boolean\", found \"true\". Argument \"gender\" has invalid value \"MALE\".\nExpected type \"Gender\", found \"MALE\".`` in file `argsInvalidValues.fixture`.");
27 | })();
28 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/metadataGenerated.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | query {
5 | node(id: 123)
6 | }
7 | `;
8 |
9 | Output:
10 | var Relay = require('react-relay');
11 | var x = (function () {
12 | return {
13 | calls: [{
14 | kind: 'Call',
15 | metadata: {},
16 | name: 'id',
17 | value: {
18 | kind: 'CallValue',
19 | callValue: 123
20 | }
21 | }],
22 | children: [{
23 | fieldName: 'id',
24 | kind: 'Field',
25 | metadata: {
26 | isGenerated: true,
27 | isRequisite: true
28 | },
29 | type: 'String'
30 | }, {
31 | fieldName: '__typename',
32 | kind: 'Field',
33 | metadata: {
34 | isGenerated: true,
35 | isRequisite: true
36 | },
37 | type: 'String'
38 | }],
39 | fieldName: 'node',
40 | kind: 'Query',
41 | metadata: {
42 | isAbstract: true,
43 | identifyingArgName: 'id'
44 | },
45 | name: 'MetadataGenerated',
46 | type: 'Node'
47 | };
48 | })();
49 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/tagRelayQL.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var RelayQL = require('react-relay/RelayQL');
3 | var x = RelayQL`
4 | query {
5 | node(id: 123) {
6 | id,
7 | },
8 | }
9 | `;
10 |
11 | Output:
12 | var RelayQL = require('react-relay/RelayQL');
13 | var x = (function () {
14 | return {
15 | calls: [{
16 | kind: 'Call',
17 | metadata: {},
18 | name: 'id',
19 | value: {
20 | kind: 'CallValue',
21 | callValue: 123
22 | }
23 | }],
24 | children: [{
25 | fieldName: 'id',
26 | kind: 'Field',
27 | metadata: {
28 | isRequisite: true
29 | },
30 | type: 'String'
31 | }, {
32 | fieldName: '__typename',
33 | kind: 'Field',
34 | metadata: {
35 | isGenerated: true,
36 | isRequisite: true
37 | },
38 | type: 'String'
39 | }],
40 | fieldName: 'node',
41 | kind: 'Query',
42 | metadata: {
43 | isAbstract: true,
44 | identifyingArgName: 'id'
45 | },
46 | name: 'TagRelayQL',
47 | type: 'Node'
48 | };
49 | })();
50 |
--------------------------------------------------------------------------------
/src/tools/RelayInternals.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule RelayInternals
10 | * @flow
11 | */
12 |
13 | 'use strict';
14 |
15 | const RelayNetworkLayer = require('RelayNetworkLayer');
16 | const RelayStoreData = require('RelayStoreData');
17 |
18 | const flattenRelayQuery = require('flattenRelayQuery');
19 | const printRelayQuery = require('printRelayQuery');
20 |
21 | /**
22 | * This module contains internal Relay modules that we expose for development
23 | * tools. They should be considered private APIs.
24 | *
25 | * @internal
26 | */
27 | var RelayInternals = {
28 | NetworkLayer: RelayNetworkLayer,
29 | DefaultStoreData: RelayStoreData.getDefaultInstance(),
30 | flattenRelayQuery: flattenRelayQuery,
31 | printRelayQuery: printRelayQuery,
32 | };
33 |
34 | module.exports = RelayInternals;
35 |
--------------------------------------------------------------------------------
/examples/star-wars/js/components/StarWarsShip.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This file provided by Facebook is for non-commercial testing and evaluation
3 | * purposes only. Facebook reserves all rights not expressly granted.
4 | *
5 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8 | * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
9 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 | */
12 |
13 | import React from 'react';
14 | import Relay from 'react-relay';
15 |
16 | class StarWarsShip extends React.Component {
17 | render() {
18 | var {ship} = this.props;
19 | return
{ship.name}
;
20 | }
21 | }
22 |
23 | export default Relay.createContainer(StarWarsShip, {
24 | fragments: {
25 | ship: () => Relay.QL`
26 | fragment on Ship {
27 | name
28 | }
29 | `,
30 | },
31 | });
32 |
--------------------------------------------------------------------------------
/src/store/RelayRecordState.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule RelayRecordState
10 | * @flow
11 | * @typechecks
12 | */
13 |
14 | 'use strict';
15 |
16 | export type RecordState = $Enum;
17 |
18 | var RelayRecordState = {
19 | /**
20 | * Record exists (either fetched from the server or produced by a local,
21 | * optimistic update).
22 | */
23 | EXISTENT: 'EXISTENT',
24 |
25 | /**
26 | * Record is known not to exist (either as the result of a mutation, or
27 | * because the server returned `null` when queried for the record).
28 | */
29 | NONEXISTENT: 'NONEXISTENT',
30 |
31 | /**
32 | * Record State is unknown because it has not yet been fetched from the
33 | * server.
34 | */
35 | UNKNOWN: 'UNKNOWN',
36 | };
37 |
38 | module.exports = RelayRecordState;
39 |
--------------------------------------------------------------------------------
/src/store/__mocks__/RelayMockCacheManager.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | var RelayMockCacheManager = {
13 | genCacheManager: function() {
14 | var mutationWriter = genMockWriter();
15 | var queryWriter = genMockWriter();
16 | return {
17 | mocks: {
18 | mutationWriter,
19 | queryWriter,
20 | },
21 | getMutationWriter:
22 | jest.genMockFunction().mockReturnValue(mutationWriter),
23 | getQueryWriter:
24 | jest.genMockFunction().mockReturnValue(queryWriter),
25 | };
26 | },
27 | };
28 |
29 | function genMockWriter() {
30 | return {
31 | writeField: jest.genMockFunction(),
32 | writeNode: jest.genMockFunction(),
33 | writeRootCall: jest.genMockFunction(),
34 | };
35 | }
36 |
37 | module.exports = RelayMockCacheManager;
38 |
--------------------------------------------------------------------------------
/src/store/filterExclusiveKeys.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule filterExclusiveKeys
10 | * @typechecks
11 | * @flow
12 | */
13 |
14 | 'use strict';
15 |
16 | var hasOwnProperty = Object.prototype.hasOwnProperty;
17 |
18 | /**
19 | * Returns two arrays of keys that contain each object's exclusive keys.
20 | */
21 | function filterExclusiveKeys(
22 | a: ?Object,
23 | b: ?Object
24 | ): [Array, Array] {
25 | var keysA = a ? Object.keys(a) : [];
26 | var keysB = b ? Object.keys(b) : [];
27 |
28 | if (keysA.length === 0 ||
29 | keysB.length === 0) {
30 | return [keysA, keysB];
31 | }
32 | return [
33 | keysA.filter(key => !hasOwnProperty.call(b, key)),
34 | keysB.filter(key => !hasOwnProperty.call(a, key)),
35 | ];
36 | }
37 |
38 | module.exports = filterExclusiveKeys;
39 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/container.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | Relay.createContainer(Component, {
4 | queries: {
5 | viewer: () => Relay.QL`fragment on Viewer { actor { id } }`
6 | }
7 | });
8 |
9 | Output:
10 | var Relay = require('react-relay');
11 | Relay.createContainer(Component, {
12 | queries: {
13 | viewer: function viewer() {
14 | return (function () {
15 | return {
16 | children: [{
17 | children: [{
18 | fieldName: 'id',
19 | kind: 'Field',
20 | metadata: {
21 | isRequisite: true
22 | },
23 | type: 'String'
24 | }],
25 | fieldName: 'actor',
26 | kind: 'Field',
27 | metadata: {
28 | inferredRootCallName: 'node',
29 | inferredPrimaryKey: 'id'
30 | },
31 | type: 'User'
32 | }],
33 | kind: 'Fragment',
34 | metadata: {},
35 | name: 'Container',
36 | type: 'Viewer'
37 | };
38 | })();
39 | }
40 | }
41 | });
42 |
--------------------------------------------------------------------------------
/src/query/RelayRefQueryDescriptor.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule RelayRefQueryDescriptor
10 | * @flow
11 | * @typechecks
12 | */
13 |
14 | 'use strict';
15 |
16 | import type RelayQuery from 'RelayQuery';
17 |
18 | export type NodePath = Array;
19 |
20 | /**
21 | * @internal
22 | *
23 | * Represents a node that will eventually become a "ref query".
24 | *
25 | * Includes the `nodePath` (ancestor nodes) that can be used to construct an
26 | * appropriate the JSONPath for the query.
27 | *
28 | * @see splitDeferredRelayQueries
29 | */
30 | class RelayRefQueryDescriptor {
31 | node: RelayQuery.Node;
32 | nodePath: NodePath;
33 |
34 | constructor(node: RelayQuery.Node, nodePath: NodePath) {
35 | this.node = node;
36 | this.nodePath = nodePath;
37 | }
38 | }
39 |
40 | module.exports = RelayRefQueryDescriptor;
41 |
--------------------------------------------------------------------------------
/src/traversal/filterRelayQuery.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule filterRelayQuery
10 | * @flow
11 | * @typechecks
12 | */
13 |
14 | 'use strict';
15 |
16 | import type RelayQuery from 'RelayQuery';
17 |
18 | type Filter = (node: RelayQuery.Node) => boolean;
19 |
20 | /**
21 | * @internal
22 | *
23 | * `filterRelayQuery` filters query nodes for which `callback` returns false.
24 | * This is intended as a generic filter module and therefore contains no special
25 | * logic for handling requisite or generated fields.
26 | */
27 | function filterRelayQuery(
28 | node: RelayQuery.Node,
29 | callback: Filter
30 | ): ?RelayQuery.Node {
31 | if (callback(node)) {
32 | return node.clone(node.getChildren().map(
33 | child => filterRelayQuery(child, callback)
34 | ));
35 | }
36 | return null;
37 | }
38 |
39 | module.exports = filterRelayQuery;
40 |
--------------------------------------------------------------------------------
/examples/star-wars/js/app.js:
--------------------------------------------------------------------------------
1 | /**
2 | * This file provided by Facebook is for non-commercial testing and evaluation
3 | * purposes only. Facebook reserves all rights not expressly granted.
4 | *
5 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
8 | * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
9 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
10 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 | */
12 |
13 | import 'babel/polyfill';
14 | import React from 'react';
15 | import ReactDOM from 'react-dom';
16 | import Relay from 'react-relay';
17 | import StarWarsApp from './components/StarWarsApp';
18 | import StarWarsAppHomeRoute from './routes/StarWarsAppHomeRoute';
19 |
20 | ReactDOM.render(
21 | ,
27 | document.getElementById('root')
28 | );
29 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/GraphQLRelayDirective.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @flow
10 | * @fullSyntaxTransform
11 | */
12 |
13 | 'use strict';
14 |
15 | const types = require('./GraphQL').type;
16 |
17 | module.exports = {
18 | name: 'relay',
19 | description: 'The @relay directive on fragments.',
20 | args: [
21 | {
22 | name: 'pattern',
23 | description:
24 | 'Marks a fragment as intended for pattern matching (as ' +
25 | 'opposed to fetching).',
26 | type: types.GraphQLBoolean,
27 | defaultValue: (null: ?boolean),
28 | },
29 | {
30 | name: 'plural',
31 | description: 'Marks a fragment as being backed by a GraphQLList',
32 | type: types.GraphQLBoolean,
33 | defaultValue: (null: ?boolean),
34 | },
35 | ],
36 | onOperation: false,
37 | onFragment: true,
38 | onField: false,
39 | };
40 |
--------------------------------------------------------------------------------
/src/route/__tests__/RelayMetaRoute-test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @emails oncall+relay
10 | */
11 |
12 | 'use strict';
13 |
14 | const RelayMetaRoute = require('RelayMetaRoute');
15 |
16 | describe('RelayMetaRoute', () => {
17 | beforeEach(() => {
18 | jest.resetModuleRegistry();
19 | });
20 |
21 | it('is immutable', () => {
22 | var route = new RelayMetaRoute('TestRoute');
23 | expect(() => route.name = 'foo').toThrow();
24 | });
25 |
26 | it('returns caches objects when using `get`', () => {
27 | expect(
28 | RelayMetaRoute.get('TestRoute')
29 | ).toBe(RelayMetaRoute.get('TestRoute'));
30 |
31 | expect(
32 | RelayMetaRoute.get('TestRoute')
33 | ).not.toBe(RelayMetaRoute.get('TestRoute2'));
34 |
35 | expect(
36 | RelayMetaRoute.get('TestRoute2')
37 | ).toBe(RelayMetaRoute.get('TestRoute2'));
38 | });
39 | });
40 |
--------------------------------------------------------------------------------
/docs/QuickStart-Videos.md:
--------------------------------------------------------------------------------
1 | ---
2 | id: videos
3 | title: Videos
4 | layout: docs
5 | category: Quick Start
6 | permalink: docs/videos.html
7 | next: guides-containers
8 | ---
9 |
10 | ## [@Scale September 2015](http://www.atscaleconference.com/)
11 |
12 |
13 |
14 | ## [ReactEurope July 2015](https://www.react-europe.org/2015/2015.html)
15 |
16 |
17 |
18 | ## [JSConf US May 2015](http://2015.jsconf.us/)
19 |
20 |
21 |
22 | ## [React.js Conf January 2015](http://conf.reactjs.com/)
23 |
24 |
25 |
26 | Now that we've gone end-to-end with Relay, let's dive into more detail in the guides section.
27 |
--------------------------------------------------------------------------------
/scripts/jest/updateSchema.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env babel-node --optional es7.asyncFunctions
2 | /**
3 | * Copyright 2013-2015, Facebook, Inc.
4 | * All rights reserved.
5 | *
6 | * This source code is licensed under the BSD-style license found in the
7 | * LICENSE file in the root directory of this source tree. An additional grant
8 | * of patent rights can be found in the PATENTS file in the same directory.
9 | */
10 |
11 | import fs from 'fs';
12 | import path from 'path';
13 | import { parse } from 'graphql/language';
14 | import { buildASTSchema, introspectionQuery } from 'graphql/utilities';
15 | import { graphql } from 'graphql';
16 |
17 | try {
18 | var inFile = path.resolve(__dirname, 'testschema.graphql');
19 | var outFile = path.resolve(__dirname, 'testschema.json');
20 |
21 | var body = fs.readFileSync(inFile, 'utf8');
22 | var ast = parse(body);
23 | var astSchema = buildASTSchema(ast, 'Root', 'Mutation');
24 | graphql(astSchema, introspectionQuery).then(
25 | function(result) {
26 | var out = JSON.stringify(result, null, 2);
27 | fs.writeFileSync(outFile, out);
28 | });
29 | } catch (error) {
30 | console.error(error);
31 | console.error(error.stack);
32 | }
33 |
--------------------------------------------------------------------------------
/src/container/__tests__/isRelayContainer-test.js:
--------------------------------------------------------------------------------
1 | // /**
2 | // * Copyright 2013-2015, Facebook, Inc.
3 | // * All rights reserved.
4 | // *
5 | // * This source code is licensed under the BSD-style license found in the
6 | // * LICENSE file in the root directory of this source tree. An additional grant
7 | // * of patent rights can be found in the PATENTS file in the same directory.
8 | // *
9 | // * @emails oncall+relay
10 | // */
11 | //
12 | // 'use strict';
13 | //
14 | // const React = require('React');
15 | // const Relay = require('Relay');
16 | //
17 | // describe('isRelayContainer', function() {
18 | // var MockComponent;
19 | // var MockContainer;
20 | //
21 | // beforeEach(function() {
22 | // jest.resetModuleRegistry();
23 | //
24 | // MockComponent = React.createClass({
25 | // render: () => ,
26 | // });
27 | //
28 | // MockContainer = Relay.createContainer(MockComponent, {
29 | // fragments: {},
30 | // });
31 | // });
32 | //
33 | // it('identifies Relay containers correctly', () => {
34 | // expect(Relay.isContainer(MockContainer)).toBe(true);
35 | //
36 | // expect(Relay.isContainer(MockComponent)).toBe(false);
37 | // });
38 | // });
39 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/queryWithVarArgs.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | query {
5 | nodes(ids: [123,456]) {
6 | id,
7 | },
8 | }
9 | `;
10 |
11 | Output:
12 | var Relay = require('react-relay');
13 | var x = (function () {
14 | return {
15 | calls: [{
16 | kind: 'Call',
17 | metadata: {},
18 | name: 'ids',
19 | value: [{
20 | kind: 'CallValue',
21 | callValue: 123
22 | }, {
23 | kind: 'CallValue',
24 | callValue: 456
25 | }]
26 | }],
27 | children: [{
28 | fieldName: 'id',
29 | kind: 'Field',
30 | metadata: {
31 | isRequisite: true
32 | },
33 | type: 'String'
34 | }, {
35 | fieldName: '__typename',
36 | kind: 'Field',
37 | metadata: {
38 | isGenerated: true,
39 | isRequisite: true
40 | },
41 | type: 'String'
42 | }],
43 | fieldName: 'nodes',
44 | kind: 'Query',
45 | metadata: {
46 | isPlural: true,
47 | isAbstract: true,
48 | identifyingArgName: 'ids'
49 | },
50 | name: 'QueryWithVarArgs',
51 | type: 'Node'
52 | };
53 | })();
54 |
--------------------------------------------------------------------------------
/src/query/callsToGraphQL.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule callsToGraphQL
10 | * @flow
11 | * @typechecks
12 | */
13 |
14 | 'use strict';
15 |
16 | import type {ConcreteCall} from 'ConcreteQuery';
17 | import type {Call} from 'RelayInternalTypes';
18 | const QueryBuilder = require('QueryBuilder');
19 |
20 | /**
21 | * @internal
22 | *
23 | * Convert from plain object `{name, value}` calls to GraphQL call nodes.
24 | */
25 | function callsToGraphQL(calls: Array): Array {
26 | return calls.map(({name, value}) => {
27 | let concreteValue = null;
28 | if (Array.isArray(value)) {
29 | concreteValue = value.map(QueryBuilder.createCallValue);
30 | } else if (value != null) {
31 | concreteValue = QueryBuilder.createCallValue(value);
32 | }
33 | return QueryBuilder.createCall(name, concreteValue);
34 | });
35 | }
36 |
37 | module.exports = callsToGraphQL;
38 |
--------------------------------------------------------------------------------
/examples/todo/README.md:
--------------------------------------------------------------------------------
1 | # Relay TodoMVC
2 |
3 | ## Installation
4 |
5 | ```
6 | npm install
7 | ```
8 |
9 | ## Running
10 |
11 | Start a local server:
12 |
13 | ```
14 | npm start
15 | ```
16 |
17 | ## Developing
18 |
19 | Any changes you make to files in the `js/` directory will cause the server to
20 | automatically rebuild the app and refresh your browser.
21 |
22 | If at any time you make changes to `data/schema.js`, stop the server,
23 | regenerate `data/schema.json`, and restart the server:
24 |
25 | ```
26 | npm run update-schema
27 | npm start
28 | ```
29 |
30 | ## License
31 |
32 | This file provided by Facebook is for non-commercial testing and evaluation
33 | purposes only. Facebook reserves all rights not expressly granted.
34 |
35 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
38 | FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
39 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 |
--------------------------------------------------------------------------------
/examples/star-wars/README.md:
--------------------------------------------------------------------------------
1 | # Relay Star Wars
2 |
3 | ## Installation
4 |
5 | ```
6 | npm install
7 | ```
8 |
9 | ## Running
10 |
11 | Start a local server:
12 |
13 | ```
14 | npm start
15 | ```
16 |
17 | ## Developing
18 |
19 | Any changes you make to files in the `js/` directory will cause the server to
20 | automatically rebuild the app and refresh your browser.
21 |
22 | If at any time you make changes to `data/schema.js`, stop the server,
23 | regenerate `data/schema.json`, and restart the server:
24 |
25 | ```
26 | npm run update-schema
27 | npm start
28 | ```
29 |
30 | ## License
31 |
32 | This file provided by Facebook is for non-commercial testing and evaluation
33 | purposes only. Facebook reserves all rights not expressly granted.
34 |
35 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
38 | FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
39 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/argsVariablesList.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var foo = Relay.QL`
3 | query Args {
4 | nodes(ids: [$one, $two, 3]) {
5 | id,
6 | },
7 | }
8 | `;
9 |
10 | Output:
11 | var foo = (function () {
12 | return {
13 | calls: [{
14 | kind: "Call",
15 | metadata: {},
16 | name: "ids",
17 | value: [{
18 | kind: "CallVariable",
19 | callVariableName: "one"
20 | }, {
21 | kind: "CallVariable",
22 | callVariableName: "two"
23 | }, {
24 | kind: "CallValue",
25 | callValue: 3
26 | }]
27 | }],
28 | children: [{
29 | fieldName: "id",
30 | kind: "Field",
31 | metadata: {
32 | isRequisite: true
33 | },
34 | type: "String"
35 | }, {
36 | fieldName: "__typename",
37 | kind: "Field",
38 | metadata: {
39 | isGenerated: true,
40 | isRequisite: true
41 | },
42 | type: "String"
43 | }],
44 | fieldName: "nodes",
45 | kind: "Query",
46 | metadata: {
47 | isPlural: true,
48 | isAbstract: true,
49 | identifyingArgName: "ids"
50 | },
51 | name: "Args",
52 | type: "Node"
53 | };
54 | })();
55 |
--------------------------------------------------------------------------------
/examples/star-wars-angular/README.md:
--------------------------------------------------------------------------------
1 | # Relay Star Wars
2 |
3 | ## Installation
4 |
5 | ```
6 | npm install
7 | ```
8 |
9 | ## Running
10 |
11 | Start a local server:
12 |
13 | ```
14 | npm start
15 | ```
16 |
17 | ## Developing
18 |
19 | Any changes you make to files in the `js/` directory will cause the server to
20 | automatically rebuild the app and refresh your browser.
21 |
22 | If at any time you make changes to `data/schema.js`, stop the server,
23 | regenerate `data/schema.json`, and restart the server:
24 |
25 | ```
26 | npm run update-schema
27 | npm start
28 | ```
29 |
30 | ## License
31 |
32 | This file provided by Facebook is for non-commercial testing and evaluation
33 | purposes only. Facebook reserves all rights not expressly granted.
34 |
35 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
38 | FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
39 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/metadataVarArgs.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | fragment on User {
5 | friends(orderby: $order) {
6 | count,
7 | },
8 | }
9 | `;
10 |
11 | Output:
12 | var Relay = require('react-relay');
13 | var x = (function () {
14 | return {
15 | children: [{
16 | calls: [{
17 | kind: 'Call',
18 | metadata: {},
19 | name: 'orderby',
20 | value: {
21 | kind: 'CallVariable',
22 | callVariableName: 'order'
23 | }
24 | }],
25 | children: [{
26 | fieldName: 'count',
27 | kind: 'Field',
28 | metadata: {},
29 | type: 'Int'
30 | }],
31 | fieldName: 'friends',
32 | kind: 'Field',
33 | metadata: {
34 | isConnection: true,
35 | isFindable: true
36 | },
37 | type: 'UserConnection'
38 | }, {
39 | fieldName: 'id',
40 | kind: 'Field',
41 | metadata: {
42 | isGenerated: true,
43 | isRequisite: true
44 | },
45 | type: 'String'
46 | }],
47 | kind: 'Fragment',
48 | metadata: {},
49 | name: 'MetadataVarArgs',
50 | type: 'User'
51 | };
52 | })();
53 |
--------------------------------------------------------------------------------
/examples/relay-treasurehunt/README.md:
--------------------------------------------------------------------------------
1 | # Relay Treasure Hunt
2 |
3 | ## Installation
4 |
5 | ```
6 | npm install
7 | ```
8 |
9 | ## Running
10 |
11 | Start a local server:
12 |
13 | ```
14 | npm start
15 | ```
16 |
17 | ## Developing
18 |
19 | Any changes you make to files in the `js/` directory will cause the server to
20 | automatically rebuild the app and refresh your browser.
21 |
22 | If at any time you make changes to `data/schema.js`, stop the server,
23 | regenerate `data/schema.json`, and restart the server:
24 |
25 | ```
26 | npm run update-schema
27 | npm start
28 | ```
29 |
30 | ## License
31 |
32 | This file provided by Facebook is for non-commercial testing and evaluation
33 | purposes only. Facebook reserves all rights not expressly granted.
34 |
35 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
38 | FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
39 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 |
--------------------------------------------------------------------------------
/scripts/babel-relay-plugin/src/__fixtures__/fieldWithEmptyArrayArg.fixture:
--------------------------------------------------------------------------------
1 | Input:
2 | var Relay = require('react-relay');
3 | var x = Relay.QL`
4 | fragment on User {
5 | friends(isViewerFriend: false) {
6 | count,
7 | },
8 | }
9 | `;
10 |
11 | Output:
12 | var Relay = require('react-relay');
13 | var x = (function () {
14 | return {
15 | children: [{
16 | calls: [{
17 | kind: 'Call',
18 | metadata: {},
19 | name: 'isViewerFriend',
20 | value: {
21 | kind: 'CallValue',
22 | callValue: false
23 | }
24 | }],
25 | children: [{
26 | fieldName: 'count',
27 | kind: 'Field',
28 | metadata: {},
29 | type: 'Int'
30 | }],
31 | fieldName: 'friends',
32 | kind: 'Field',
33 | metadata: {
34 | isConnection: true,
35 | isFindable: true
36 | },
37 | type: 'UserConnection'
38 | }, {
39 | fieldName: 'id',
40 | kind: 'Field',
41 | metadata: {
42 | isGenerated: true,
43 | isRequisite: true
44 | },
45 | type: 'String'
46 | }],
47 | kind: 'Fragment',
48 | metadata: {},
49 | name: 'FieldWithEmptyArrayArg',
50 | type: 'User'
51 | };
52 | })();
53 |
--------------------------------------------------------------------------------
/src/query/getConcreteFragmentHash.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule getConcreteFragmentHash
10 | * @typechecks
11 | * @flow
12 | */
13 |
14 | 'use strict';
15 |
16 | import type {ConcreteFragment} from 'ConcreteQuery';
17 |
18 | let _nextFragmentID = 0;
19 |
20 | /**
21 | * The "concrete hash" of a fragment uniquely identifies the instance of the
22 | * concrete node. This method should be used with `RelayQueryFragment#isCloned`
23 | * if you may be dealing with fragments that have been cloned with new children.
24 | *
25 | * This hash may change between runtime sessions (e.g. client and server).
26 | */
27 | function getConcreteFragmentHash(fragment: ConcreteFragment): string {
28 | let instanceHash = (fragment: any).__instanceHash__;
29 | if (instanceHash == null) {
30 | instanceHash = (_nextFragmentID++).toString();
31 | (fragment: any).__instanceHash__ = instanceHash;
32 | }
33 | return instanceHash;
34 | }
35 |
36 | module.exports = getConcreteFragmentHash;
37 |
--------------------------------------------------------------------------------
/src/network/__mocks__/fetchRelayQuery.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | */
9 |
10 | 'use strict';
11 |
12 | var fetchRelayQuery = jest.genMockFromModule('fetchRelayQuery');
13 |
14 | /**
15 | * Mock object to simulate the behavior of a request. Example usage:
16 | *
17 | * // Successful fetch.
18 | * fetchRelayQuery(queryA);
19 | * fetchRelayQuery.mock.requests[0].resolve(response);
20 | *
21 | * // Fetch with partial error.
22 | * fetchRelayQuery(queryB);
23 | * fetchRelayQuery.mock.requests[0].resolve(response, error);
24 | *
25 | * // Failed fetch.
26 | * fetchRelayQuery(queryC);
27 | * fetchRelayQuery.mock.requests[0].reject(error);
28 | *
29 | */
30 | function genMockRequest(resolve, reject) {
31 | fetchRelayQuery.mock.requests.push({
32 | resolve(response, error) {
33 | resolve({error: error || null, response});
34 | },
35 | reject,
36 | });
37 | }
38 |
39 | fetchRelayQuery.mock.requests = [];
40 | fetchRelayQuery.mockImplementation(() => new Promise(genMockRequest));
41 |
42 | module.exports = fetchRelayQuery;
43 |
--------------------------------------------------------------------------------
/website/core/HeaderLinks.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2013-2015, Facebook, Inc.
3 | * All rights reserved.
4 | *
5 | * This source code is licensed under the BSD-style license found in the
6 | * LICENSE file in the root directory of this source tree. An additional grant
7 | * of patent rights can be found in the PATENTS file in the same directory.
8 | *
9 | * @providesModule HeaderLinks
10 | */
11 |
12 | var HeaderLinks = React.createClass({
13 | links: [
14 | {section: 'playground', href: '/relay/prototyping/playground.html', text: 'Try it out'},
15 | {section: 'docs', href: '/relay/docs/getting-started.html#content', text: 'Docs'},
16 | {section: 'support', href: '/relay/support.html', text: 'Support'},
17 | {section: 'github', href: 'https://github.com/facebook/relay', text: 'GitHub'},
18 | ],
19 |
20 | render: function() {
21 | return (
22 |