Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (fragmentRefPathInResponse.includes('node')) {
// @refetchable fragments are guaranteed to have an `id` selection
// if the type is Node or implements Node. Double-check that there
// actually is a value at runtime.
if (typeof dataID !== 'string') {
warning(
false,
'Relay: Expected result to have a string ' +
'`id` in order to refetch/paginate, got `%s`.',
dataID,
);
}
paginationVariables.id = dataID;
}
const paginationQuery = createOperationDescriptor(
paginationRequest,
paginationVariables,
);
fetchQuery(environment, paginationQuery, {
networkCacheConfig: {force: true},
}).subscribe({
...observer,
start: subscription => {
startFetch(subscription);
observer.start && observer.start(subscription);
},
complete: () => {
completeFetch();
observer.complete && observer.complete();
onComplete && onComplete(null);
},
rootVariables = _assertRelayContext.variables;
var fetchVariables = typeof refetchVariables === 'function' ? refetchVariables(this._getFragmentVariables()) : refetchVariables;
fetchVariables = _objectSpread2({}, rootVariables, {}, fetchVariables);
var fragmentVariables = renderVariables ? _objectSpread2({}, fetchVariables, {}, renderVariables) : fetchVariables;
var cacheConfig = options ? {
force: !!options.force
} : undefined;
var observer = typeof observerOrCallback === 'function' ? {
// callback is not exectued on complete or unsubscribe
// for backward compatibility
next: observerOrCallback,
error: observerOrCallback
} : observerOrCallback || {};
var query = getRequest(taggedNode);
var operation = createOperationDescriptor(query, fetchVariables); // TODO: T26288752 find a better way
this.state.localVariables = fetchVariables; // Cancel any previously running refetch.
this._refetchSubscription && this._refetchSubscription.unsubscribe(); // Declare refetchSubscription before assigning it in .start(), since
// synchronous completion may call callbacks .subscribe() returns.
var refetchSubscription;
if (options && options.fetchPolicy === 'store-or-network') {
var storeSnapshot = this._getQueryFetcher().lookupInStore(environment, operation);
if (storeSnapshot != null) {
this.state.resolver.setVariables(fragmentVariables, operation.node);
this.setState(function (latestState) {
return {
data: latestState.resolver.resolve(),
: fetchVariables
const cacheConfig = options ? { force: !!options.force } : undefined
const observer =
typeof observerOrCallback === 'function'
? {
// callback is not exectued on complete or unsubscribe
// for backward compatibility
next: observerOrCallback,
error: observerOrCallback
}
: observerOrCallback || ({})
const query = getRequest(taggedNode)
const operation = createOperationDescriptor(query, fetchVariables)
// TODO: T26288752 find a better way
this.state.localVariables = fetchVariables
// Cancel any previously running refetch.
this._refetchSubscription && this._refetchSubscription.unsubscribe()
// Declare refetchSubscription before assigning it in .start(), since
// synchronous completion may call callbacks .subscribe() returns.
let refetchSubscription
if (options && options.fetchPolicy === 'store-or-network') {
const storeSnapshot = this._getQueryFetcher().lookupInStore(
environment,
operation
)
rootVariables = _assertRelayContext.variables;
var fetchVariables = typeof refetchVariables === 'function' ? refetchVariables(this._getFragmentVariables()) : refetchVariables;
fetchVariables = _objectSpread2({}, rootVariables, {}, fetchVariables);
var fragmentVariables = renderVariables ? _objectSpread2({}, fetchVariables, {}, renderVariables) : fetchVariables;
var cacheConfig = options ? {
force: !!options.force
} : undefined;
var observer = typeof observerOrCallback === 'function' ? {
// callback is not exectued on complete or unsubscribe
// for backward compatibility
next: observerOrCallback,
error: observerOrCallback
} : observerOrCallback || {};
var query = relayRuntime.getRequest(taggedNode);
var operation = relayRuntime.createOperationDescriptor(query, fetchVariables); // TODO: T26288752 find a better way
this.state.localVariables = fetchVariables; // Cancel any previously running refetch.
this._refetchSubscription && this._refetchSubscription.unsubscribe(); // Declare refetchSubscription before assigning it in .start(), since
// synchronous completion may call callbacks .subscribe() returns.
var refetchSubscription;
if (options && options.fetchPolicy === 'store-or-network') {
var storeSnapshot = this._getQueryFetcher().lookupInStore(environment, operation);
if (storeSnapshot != null) {
this.state.resolver.setVariables(fragmentVariables, operation.node);
this.setState(function (latestState) {
return {
data: latestState.resolver.resolve(),
);
fetchVariables = {
...fetchVariables,
...this._refetchVariables,
};
fragmentVariables = {
...fetchVariables,
...fragmentVariables,
};
const cacheConfig: CacheConfig = options ? { force: !!options.force } : undefined;
if (cacheConfig != null && options && options.metadata != null) {
cacheConfig.metadata = options.metadata;
}
const request = getRequest(connectionConfig.query);
const operation = createOperationDescriptor(request, fetchVariables);
let refetchSubscription = null;
if (this._refetchSubscription) {
this._refetchSubscription.unsubscribe();
}
this._hasFetched = true;
const onNext = (payload, complete) => {
const contextVariables = {
...fragmentVariables,
};
const prevData = resolver.resolve();
resolver.setVariables(
this._getFragmentVariables(fragmentVariables, paginatingVariables.totalCount),
operation.node || operation.request.node,
...fetchVariables,
...this._refetchVariables,
};
fragmentVariables = {
...fetchVariables,
...fragmentVariables,
};
const cacheConfig: ?CacheConfig = options
? {force: !!options.force}
: undefined;
if (cacheConfig != null && options?.metadata != null) {
cacheConfig.metadata = options?.metadata;
}
const request = getRequest(connectionConfig.query);
const operation = createOperationDescriptor(request, fetchVariables);
let refetchSubscription = null;
if (this._refetchSubscription) {
this._refetchSubscription.unsubscribe();
}
this._hasFetched = true;
const onNext = (payload, complete) => {
const prevData = this._resolver.resolve();
this._resolver.setVariables(
getFragmentVariables(
fragmentVariables,
paginatingVariables.totalCount,
),
operation.request.node,
super(props);
invariant(
React.Children.count(this.props.children) === 1,
'Expected only a single child to be passed to `RelayTestContainer`',
);
invariant(
React.isValidElement(this.props.children),
'Expected child of `RelayTestContainer` to be a React element',
);
const {query, environment, variables} = props;
const operation = getRequest((query: $FlowFixMe));
const operationDescriptor = createOperationDescriptor(operation, variables);
const snapshot = environment.lookup(
operationDescriptor.fragment,
operationDescriptor,
);
this.state = {data: snapshot.data};
environment.subscribe(snapshot, this._onChange);
}
params = query.params;
}
const network = environment.getNetwork();
const fetchPolicy = options?.fetchPolicy ?? STORE_OR_NETWORK_DEFAULT;
const fetchKey = options?.fetchKey;
const networkCacheConfig = options?.networkCacheConfig ?? {force: true};
const cacheKey = `${getRequestIdentifier(params, variables)}${
fetchKey != null ? `-${fetchKey}` : ''
}`;
const prevQueryEntry = pendingQueries.get(cacheKey);
const shouldFulfillFromCache =
fetchPolicy === STORE_OR_NETWORK_DEFAULT &&
query != null &&
(prevQueryEntry?.kind === 'cache' ||
environment.check(createOperationDescriptor(query, variables)) ===
'available');
let nextQueryEntry;
if (shouldFulfillFromCache) {
nextQueryEntry =
prevQueryEntry && prevQueryEntry.kind === 'cache'
? prevQueryEntry
: {
cacheKey,
fetchKey,
fetchPolicy,
kind: 'cache',
name: params.name,
};
if (ExecutionEnvironment.canUseDOM && prevQueryEntry == null) {
setTimeout(() => {
super(props);
invariant(
React.Children.count(this.props.children) === 1,
'Expected only a single child to be passed to `RelayTestContainer`',
);
invariant(
React.isValidElement(this.props.children),
'Expected child of `RelayTestContainer` to be a React element',
);
const {query, environment, variables} = props;
const operation = getRequest((query: $FlowFixMe));
const operationDescriptor = createOperationDescriptor(operation, variables);
const snapshot = environment.lookup(
operationDescriptor.fragment,
operationDescriptor,
);
this.state = {data: snapshot.data};
environment.subscribe(snapshot, this._onChange);
}