Skip to content

Commit

Permalink
remove exhcanges from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Mar 15, 2023
1 parent 085162d commit df21498
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 84 deletions.
3 changes: 2 additions & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ Whenever we decide to send a request to our API we start by using `urql`'s
extra information on how the GraphQL requests are executed.

```js
import { Client } from '@urql/core';
import { Client, dedupExchange, cacheExchange, fetchExchange } from '@urql/core';

new Client({
url: 'http://localhost:3000/graphql',
requestPolicy: 'cache-first',
exchanges: [dedupExchange, cacheExchange, fetchExchange]
});
```

Expand Down
5 changes: 1 addition & 4 deletions exchanges/auth/src/authExchange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ import {
Client,
Operation,
OperationResult,
dedupExchange,
cacheExchange,
fetchExchange,
} from '@urql/core';

import { vi, expect, it } from 'vitest';
Expand All @@ -45,7 +42,7 @@ const makeExchangeArgs = () => {
),
client: new Client({
url: '/api',
exchanges: [dedupExchange, cacheExchange, fetchExchange],
exchanges: [],
}),
} as any,
};
Expand Down
5 changes: 1 addition & 4 deletions exchanges/context/src/context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import {
Operation,
OperationResult,
ExchangeIO,
dedupExchange,
cacheExchange,
fetchExchange,
} from '@urql/core';

import { contextExchange } from './context';
Expand Down Expand Up @@ -37,7 +34,7 @@ let client, op, ops$, next;
beforeEach(() => {
client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange, fetchExchange],
exchanges: [],
});
op = client.createRequestOperation('query', {
key: 1,
Expand Down
50 changes: 24 additions & 26 deletions exchanges/graphcache/src/cacheExchange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import {
Operation,
OperationResult,
CombinedError,
dedupExchange,
fetchExchange,
} from '@urql/core';
import { vi, expect, it, describe } from 'vitest';

Expand Down Expand Up @@ -58,7 +56,7 @@ describe('data dependencies', () => {
it('writes queries to the cache', () => {
const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const op = client.createRequestOperation('query', {
key: 1,
Expand Down Expand Up @@ -118,7 +116,7 @@ describe('data dependencies', () => {
it('respects cache-only operations', () => {
const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const op = client.createRequestOperation(
'query',
Expand Down Expand Up @@ -184,7 +182,7 @@ describe('data dependencies', () => {

const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next } = makeSubject<Operation>();

Expand Down Expand Up @@ -317,7 +315,7 @@ describe('data dependencies', () => {

const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next } = makeSubject<Operation>();

Expand Down Expand Up @@ -427,7 +425,7 @@ describe('data dependencies', () => {

const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next } = makeSubject<Operation>();
const reexec = vi
Expand Down Expand Up @@ -492,7 +490,7 @@ describe('data dependencies', () => {

const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next } = makeSubject<Operation>();

Expand Down Expand Up @@ -552,7 +550,7 @@ describe('data dependencies', () => {

const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next } = makeSubject<Operation>();

Expand Down Expand Up @@ -608,7 +606,7 @@ describe('data dependencies', () => {
it('marks errored null fields as uncached but delivers them as expected', () => {
const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next } = makeSubject<Operation>();

Expand Down Expand Up @@ -708,7 +706,7 @@ describe('optimistic updates', () => {

const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next } = makeSubject<Operation>();

Expand Down Expand Up @@ -804,7 +802,7 @@ describe('optimistic updates', () => {

const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next } = makeSubject<Operation>();

Expand Down Expand Up @@ -904,7 +902,7 @@ describe('optimistic updates', () => {

const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next } = makeSubject<Operation>();

Expand Down Expand Up @@ -1024,7 +1022,7 @@ describe('optimistic updates', () => {

const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next } = makeSubject<Operation>();

Expand Down Expand Up @@ -1110,7 +1108,7 @@ describe('custom resolvers', () => {
it('follows resolvers on initial write', () => {
const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next } = makeSubject<Operation>();

Expand Down Expand Up @@ -1186,7 +1184,7 @@ describe('custom resolvers', () => {

const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next } = makeSubject<Operation>();

Expand Down Expand Up @@ -1273,7 +1271,7 @@ describe('custom resolvers', () => {

const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next } = makeSubject<Operation>();

Expand Down Expand Up @@ -1442,7 +1440,7 @@ describe('schema awareness', () => {
vi.useFakeTimers();
const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next } = makeSubject<Operation>();
const reexec = vi
Expand Down Expand Up @@ -1588,7 +1586,7 @@ describe('schema awareness', () => {
vi.useFakeTimers();
const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next } = makeSubject<Operation>();
const reexec = vi
Expand Down Expand Up @@ -1714,7 +1712,7 @@ describe('commutativity', () => {
const client = createClient({
url: 'http://0.0.0.0',
requestPolicy: 'cache-and-network',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next: next } = makeSubject<Operation>();
const query = gql`
Expand Down Expand Up @@ -1802,7 +1800,7 @@ describe('commutativity', () => {
let data: any;
const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next: nextOp } = makeSubject<Operation>();
const { source: res$, next: nextRes } = makeSubject<OperationResult>();
Expand Down Expand Up @@ -1895,7 +1893,7 @@ describe('commutativity', () => {
let data: any;
const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next: nextOp } = makeSubject<Operation>();
const { source: res$, next: nextRes } = makeSubject<OperationResult>();
Expand Down Expand Up @@ -2014,7 +2012,7 @@ describe('commutativity', () => {
let data: any;
const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next: nextOp } = makeSubject<Operation>();
const { source: res$, next: nextRes } = makeSubject<OperationResult>();
Expand Down Expand Up @@ -2116,7 +2114,7 @@ describe('commutativity', () => {
let data: any;
const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next: nextOp } = makeSubject<Operation>();
const { source: res$, next: nextRes } = makeSubject<OperationResult>();
Expand Down Expand Up @@ -2214,7 +2212,7 @@ describe('commutativity', () => {
let data: any;
const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next: nextOp } = makeSubject<Operation>();
const { source: res$, next: nextRes } = makeSubject<OperationResult>();
Expand Down Expand Up @@ -2354,7 +2352,7 @@ describe('commutativity', () => {

const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange({}), fetchExchange],
exchanges: [],
});
const { source: ops$, next: nextOp } = makeSubject<Operation>();
const { source: res$, next: nextRes } = makeSubject<OperationResult>();
Expand Down
11 changes: 4 additions & 7 deletions exchanges/graphcache/src/offlineExchange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import {
ExchangeIO,
Operation,
OperationResult,
dedupExchange,
cacheExchange,
fetchExchange,
} from '@urql/core';
import { print } from 'graphql';
import { vi, expect, it, describe } from 'vitest';
Expand Down Expand Up @@ -67,7 +64,7 @@ describe('storage', () => {
it('should read the metadata and dispatch operations on initialization', () => {
const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange, fetchExchange],
exchanges: [],
});
const reexecuteOperation = vi
.spyOn(client, 'reexecuteOperation')
Expand Down Expand Up @@ -108,7 +105,7 @@ describe('offline', () => {

const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange, fetchExchange],
exchanges: [],
});
const queryOp = client.createRequestOperation('query', {
key: 1,
Expand Down Expand Up @@ -187,7 +184,7 @@ describe('offline', () => {
it('should intercept errored queries', async () => {
const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange, fetchExchange],
exchanges: [],
});
const onlineSpy = vi
.spyOn(navigator, 'onLine', 'get')
Expand Down Expand Up @@ -255,7 +252,7 @@ describe('offline', () => {

const client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange, fetchExchange],
exchanges: [],
});
const reexecuteOperation = vi
.spyOn(client, 'reexecuteOperation')
Expand Down
5 changes: 1 addition & 4 deletions exchanges/refocus/src/refocusExchange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import {
Operation,
OperationResult,
ExchangeIO,
dedupExchange,
cacheExchange,
fetchExchange,
} from '@urql/core';

import { refocusExchange } from './refocusExchange';
Expand Down Expand Up @@ -38,7 +35,7 @@ let client, op, ops$, next;
beforeEach(() => {
client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange, fetchExchange],
exchanges: [],
});
op = client.createRequestOperation('query', {
key: 1,
Expand Down
5 changes: 1 addition & 4 deletions exchanges/request-policy/src/requestPolicyExchange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import {
Operation,
OperationResult,
ExchangeIO,
dedupExchange,
cacheExchange,
fetchExchange,
} from '@urql/core';

import { requestPolicyExchange } from './requestPolicyExchange';
Expand Down Expand Up @@ -42,7 +39,7 @@ let client, op, ops$, next;
beforeEach(() => {
client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange, fetchExchange],
exchanges: [],
});
op = client.createRequestOperation('query', {
key: 1,
Expand Down
5 changes: 1 addition & 4 deletions exchanges/retry/src/retryExchange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import {
Operation,
OperationResult,
ExchangeIO,
dedupExchange,
cacheExchange,
fetchExchange,
} from '@urql/core';

import { retryExchange } from './retryExchange';
Expand Down Expand Up @@ -60,7 +57,7 @@ let client, op, ops$, next;
beforeEach(() => {
client = createClient({
url: 'http://0.0.0.0',
exchanges: [dedupExchange, cacheExchange, fetchExchange],
exchanges: [],
});
op = client.createRequestOperation('query', {
key: 1,
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import { Exchange, Operation, OperationResult } from './types';
import { makeOperation } from './utils';
import { Client, createClient } from './client';
import { queryOperation, subscriptionOperation } from './test-utils';
import { cacheExchange, dedupExchange, fetchExchange } from '.';

const url = 'https://hostname.com';

Expand Down Expand Up @@ -81,7 +80,7 @@ const subscription = {
let receivedOps: Operation[] = [];
let client = createClient({
url: '1234',
exchanges: [dedupExchange, cacheExchange, fetchExchange],
exchanges: [],
});
const receiveMock = vi.fn((s: Source<Operation>) =>
pipe(
Expand Down
Loading

0 comments on commit df21498

Please sign in to comment.