Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(opts: ClientOptions) {
this.url = opts.url;
this.fetchOptions = opts.fetchOptions;
this.fetch = opts.fetch;
this.suspense = !!opts.suspense;
this.requestPolicy = opts.requestPolicy || 'cache-first';
// This subject forms the input of operations; executeOperation may be
// called to dispatch a new operation on the subject
const [operations$, nextOperation] = makeSubject();
this.operations$ = operations$;
// Internally operations aren't always dispatched immediately
// Since exchanges can dispatch and reexecute operations themselves,
// if we're inside an exchange we instead queue the operation and flush
// them in order after
const queuedOperations: Operation[] = [];
let isDispatching = false;
this.dispatchOperation = (operation: Operation) => {
queuedOperations.push(operation);
if (!isDispatching) {
isDispatching = true;
let queued;
while ((queued = queuedOperations.shift()) !== undefined)
nextOperation(queued);
constructor(props) {
super(props);
if (
process.env.NODE_ENV !== 'production' &&
props.subscription &&
!props.updateSubscription
) {
throw new Error(
'You instantiated an Urql Client component with a subscription but forgot an updateSubscription prop. updateSubscription callbacks are required to work with subscriptions.'
);
}
const [queryProp$, nextQueryProp] = makeSubject();
const [
subscriptionProp$,
nextSubscriptionProp,
] = makeSubject();
this.nextQueryProp = nextQueryProp;
this.nextSubscriptionProp = nextSubscriptionProp;
const queryResults$ = makeQueryResults$(props.client, queryProp$);
const subscriptionResults$ = makeSubscriptionResults$(
props.client,
subscriptionProp$
);
const [queryTeardown] = pipe(
queryResults$,
subscribe(this.onQueryUpdate)