Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private prepareObservableQueryOptions() {
const options = this.getOptions();
this.verifyDocumentType(options.query, DocumentType.Query);
const displayName = options.displayName || 'Query';
// Set the fetchPolicy to cache-first for network-only and cache-and-network
// fetches for server side renders.
if (
this.context &&
this.context.renderPromises &&
(options.fetchPolicy === 'network-only' ||
options.fetchPolicy === 'cache-and-network')
) {
options.fetchPolicy = 'cache-first';
}
return {
...options,
displayName,
Query.prototype.extractOptsFromProps = function (props) {
this.operation = parser(props.query);
invariant(this.operation.type === DocumentType.Query, "The component requires a graphql query, but got a " + (this.operation.type === DocumentType.Mutation
? 'mutation'
: 'subscription') + ".");
var displayName = props.displayName || 'Query';
return tslib_1.__assign({}, props, { displayName: displayName, context: props.context || {}, metadata: { reactComponent: { displayName: displayName } } });
};
Query.prototype.initializeObservableQuery = function (client, props, context) {
_this.verifyDocumentIsMutation = function (mutation) {
var operation = parser(mutation);
process.env.NODE_ENV === "production" ? invariant(operation.type === DocumentType.Mutation) : invariant(operation.type === DocumentType.Mutation, "The component requires a graphql mutation, but got a " + (operation.type === DocumentType.Query ? 'query' : 'subscription') + ".");
};
_this.verifyDocumentIsMutation(props.mutation);
Partial>
>(
document: DocumentNode,
operationOptions: OperationOption<
TProps,
TData,
TGraphQLVariables,
TChildProps
> = {}
) {
switch (parser(document).type) {
case DocumentType.Mutation:
return withMutation(document, operationOptions);
case DocumentType.Subscription:
return withSubscription(document, operationOptions);
case DocumentType.Query:
default:
return withQuery(document, operationOptions);
}
}