Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public watchQuery(
options: WatchQueryOptions,
shouldSubscribe = true,
): ObservableQuery {
if (options.fetchPolicy === 'standby') {
throw new Error(
'client.watchQuery cannot be called with fetchPolicy set to "standby"',
);
}
// get errors synchronously
const queryDefinition = getQueryDefinition(options.query);
// assign variable default values if supplied
if (
queryDefinition.variableDefinitions &&
queryDefinition.variableDefinitions.length
) {
const defaultValues = getDefaultValues(queryDefinition);
options.variables = assign({}, defaultValues, options.variables);
}
if (typeof options.notifyOnNetworkStatusChange === 'undefined') {
options.notifyOnNetworkStatusChange = false;
}
let transformedOptions = { ...options } as WatchQueryOptions;
export function diffQueryAgainstStore({
store,
query,
variables,
previousResult,
returnPartialData = true,
rootId = 'ROOT_QUERY',
fragmentMatcherFunction,
config,
}: DiffQueryAgainstStoreOptions): Cache.DiffResult {
// Throw the right validation error by trying to find a query in the document
const queryDefinition = getQueryDefinition(query);
variables = assign({}, getDefaultValues(queryDefinition), variables);
const context: ReadStoreContext = {
// Global settings
store,
returnPartialData,
customResolvers: (config && config.customResolvers) || {},
// Flag set during execution
hasMissingField: false,
};
const rootIdValue = {
type: 'id',
id: rootId,
previousResult,
public diffQueryAgainstStore({
store,
query,
variables,
previousResult,
returnPartialData = true,
rootId = 'ROOT_QUERY',
fragmentMatcherFunction,
config,
}: DiffQueryAgainstStoreOptions): Cache.DiffResult {
// Throw the right validation error by trying to find a query in the document
const queryDefinition = getQueryDefinition(query);
variables = assign({}, getDefaultValues(queryDefinition), variables);
const context: ReadStoreContext = {
// Global settings
store,
dataIdFromObject: config && config.dataIdFromObject,
cacheRedirects: (config && config.cacheRedirects) || {},
};
const execResult = this.executeStoreQuery({
query,
rootValue: {
type: 'id',
id: rootId,
generated: true,
QueryManager.prototype.watchQuery = function (options, shouldSubscribe) {
if (shouldSubscribe === void 0) { shouldSubscribe = true; }
if (options.fetchPolicy === 'standby') {
throw new Error('client.watchQuery cannot be called with fetchPolicy set to "standby"');
}
var queryDefinition = getQueryDefinition(options.query);
if (queryDefinition.variableDefinitions &&
queryDefinition.variableDefinitions.length) {
var defaultValues = getDefaultValues(queryDefinition);
options.variables = assign({}, defaultValues, options.variables);
}
if (typeof options.notifyOnNetworkStatusChange === 'undefined') {
options.notifyOnNetworkStatusChange = false;
}
var transformedOptions = __assign({}, options);
return new ObservableQuery({
scheduler: this.scheduler,
options: transformedOptions,
shouldSubscribe: shouldSubscribe,
});
};
QueryManager.prototype.query = function (options) {
public removeObservableQuery(queryId: string) {
const { observableQuery } = this.getQuery(queryId);
if (!observableQuery) return;
const definition = getQueryDefinition(observableQuery.options.query);
const queryName = definition.name ? definition.name.value : null;
this.setQuery(queryId, () => ({ observableQuery: null }));
if (queryName) {
this.queryIdsByName[queryName] = this.queryIdsByName[
queryName
].filter(val => {
return !(observableQuery.queryId === val);
});
}
}
QueryManager.prototype.addObservableQuery = function (queryId, observableQuery) {
this.setQuery(queryId, function () { return ({ observableQuery: observableQuery }); });
var queryDef = getQueryDefinition(observableQuery.options.query);
if (queryDef.name && queryDef.name.value) {
var queryName = queryDef.name.value;
this.queryIdsByName[queryName] = this.queryIdsByName[queryName] || [];
this.queryIdsByName[queryName].push(observableQuery.queryId);
}
};
QueryManager.prototype.removeObservableQuery = function (queryId) {
export function diffQueryAgainstStore(_a) {
var store = _a.store, query = _a.query, variables = _a.variables, previousResult = _a.previousResult, _b = _a.returnPartialData, returnPartialData = _b === void 0 ? true : _b, _c = _a.rootId, rootId = _c === void 0 ? 'ROOT_QUERY' : _c, fragmentMatcherFunction = _a.fragmentMatcherFunction, config = _a.config;
var queryDefinition = getQueryDefinition(query);
variables = assign({}, getDefaultValues(queryDefinition), variables);
var context = {
store: store,
returnPartialData: returnPartialData,
cacheResolvers: (config && config.cacheResolvers) || {},
hasMissingField: false,
};
var rootIdValue = {
type: 'id',
id: rootId,
previousResult: previousResult,
};
var result = graphqlAnywhere(readStoreResolver, query, rootIdValue, context, variables, {
fragmentMatcher: fragmentMatcherFunction,
resultMapper: resultMapper,
});