Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { Client, SingleExample, SingleRawExample, Observer } from '../src';
declare module 'relay-runtime' {
// https://github.com/facebook/relay/blob/v1.6.0/packages/relay-runtime/query/RelayModernGraphQLTag.js#L68
export function getRequest(node: GraphQLTaggedNode): RequestNode;
// https://github.com/facebook/relay/blob/v1.6.0/packages/relay-runtime/store/RelayModernOperationSelector.js#L28
export function createOperationSelector(
request: RequestNode,
variables: Variables,
operationFromBatch?: ConcreteOperationDefinition,
): OperationSelector;
}
// https://github.com/facebook/relay/blob/v1.6.0/packages/relay-compiler/bin/RelayCompilerBin.js#L208-L214
const TRANSFORMS = {
commonTransforms: relayCompiler.IRTransforms.commonTransforms,
codegenTransforms: relayCompiler.IRTransforms.codegenTransforms,
fragmentTransforms: relayCompiler.IRTransforms.fragmentTransforms,
printTransforms: relayCompiler.IRTransforms.printTransforms,
queryTransforms: relayCompiler.IRTransforms.queryTransforms,
};
class RelayObserver implements Observer {
private _mostRecentResult?: any = null;
private _disposable: relayRuntime.Disposable;
constructor(client: relayRuntime.Environment, operation: relayRuntime.OperationSelector) {
const initialSnapshot = client.lookup(operation.root);
this._onNewSnapshot(initialSnapshot);
this._disposable = client.subscribe(initialSnapshot, this._onNewSnapshot);
}
var _relayCompiler = require("relay-compiler");
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
const {
commonTransforms,
codegenTransforms,
fragmentTransforms,
printTransforms,
queryTransforms,
schemaExtensions
} = _relayCompiler.IRTransforms; // Taken from relay-compiler/bin/RelayCompilerMain.js
var _default = (languagePlugin, config) => ({
onlyValidate,
schema,
documents,
baseDocuments,
sourceControl,
reporter
}) => _relayCompiler.FileWriter.writeAll({
config: _objectSpread({
customScalars: {}
}, config, {
compilerTransforms: {
commonTransforms,
codegenTransforms,
fragmentTransforms,
declare module 'relay-runtime' {
// https://github.com/facebook/relay/blob/v1.6.0/packages/relay-runtime/query/RelayModernGraphQLTag.js#L68
export function getRequest(node: GraphQLTaggedNode): RequestNode;
// https://github.com/facebook/relay/blob/v1.6.0/packages/relay-runtime/store/RelayModernOperationSelector.js#L28
export function createOperationSelector(
request: RequestNode,
variables: Variables,
operationFromBatch?: ConcreteOperationDefinition,
): OperationSelector;
}
// https://github.com/facebook/relay/blob/v1.6.0/packages/relay-compiler/bin/RelayCompilerBin.js#L208-L214
const TRANSFORMS = {
commonTransforms: relayCompiler.IRTransforms.commonTransforms,
codegenTransforms: relayCompiler.IRTransforms.codegenTransforms,
fragmentTransforms: relayCompiler.IRTransforms.fragmentTransforms,
printTransforms: relayCompiler.IRTransforms.printTransforms,
queryTransforms: relayCompiler.IRTransforms.queryTransforms,
};
class RelayObserver implements Observer {
private _mostRecentResult?: any = null;
private _disposable: relayRuntime.Disposable;
constructor(client: relayRuntime.Environment, operation: relayRuntime.OperationSelector) {
const initialSnapshot = client.lookup(operation.root);
this._onNewSnapshot(initialSnapshot);
this._disposable = client.subscribe(initialSnapshot, this._onNewSnapshot);
}
_onNewSnapshot = (snapshot: relayRuntime.Snapshot) => {
this._mostRecentResult = {
var _getRelayCompilerPluginHooks = _interopRequireDefault(require("./getRelayCompilerPluginHooks"));
var _createRaiseErrorsReporter = _interopRequireDefault(require("./createRaiseErrorsReporter"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
const {
schemaExtensions
} = _relayCompiler.IRTransforms;
function createParserConfigs({
baseDir,
getParser,
sourceParserName,
languagePlugin,
include,
exclude,
schema,
extensions
}) {
const sourceModuleParser = (0, _RelaySourceModuleParser.default)(languagePlugin.findGraphQLTags);
const fileOptions = {
extensions,
include,
exclude