@shopify/graphql-testing
Advanced tools
Comparing version 0.0.0-snapshot-20220623162708 to 0.0.0-snapshot-20220706153926
@@ -5,5 +5,3 @@ 'use strict'; | ||
var apolloLink = require('apollo-link'); | ||
var apolloCacheInmemory = require('apollo-cache-inmemory'); | ||
var client = require('./client.js'); | ||
var client = require('@apollo/client'); | ||
var operations = require('./operations.js'); | ||
@@ -16,4 +14,5 @@ var utilities = require('./utilities.js'); | ||
constructor(mock, { | ||
unionOrIntersectionTypes = [], | ||
cacheOptions = {} | ||
possibleTypes = {}, | ||
cacheOptions = {}, | ||
links = [] | ||
} = {}) { | ||
@@ -35,18 +34,12 @@ this.client = void 0; | ||
const cache = new apolloCacheInmemory.InMemoryCache({ | ||
fragmentMatcher: new apolloCacheInmemory.IntrospectionFragmentMatcher({ | ||
introspectionQueryResultData: { | ||
__schema: { | ||
types: unionOrIntersectionTypes | ||
} | ||
} | ||
}), | ||
const cache = new client.InMemoryCache({ | ||
possibleTypes, | ||
...cacheOptions | ||
}); | ||
this.mockLink = new mocks.MockLink(mock || defaultGraphQLMock); | ||
const link = apolloLink.ApolloLink.from([new inflight.InflightLink({ | ||
const link = client.ApolloLink.from([...links, new inflight.InflightLink({ | ||
onCreated: this.handleCreate, | ||
onResolved: this.handleResolve | ||
}), this.mockLink]); | ||
this.client = new client.TestingApolloClient({ | ||
this.client = new client.ApolloClient({ | ||
link, | ||
@@ -53,0 +46,0 @@ cache |
@@ -5,5 +5,5 @@ 'use strict'; | ||
var apolloLink = require('apollo-link'); | ||
var client = require('@apollo/client'); | ||
class InflightLink extends apolloLink.ApolloLink { | ||
class InflightLink extends client.ApolloLink { | ||
constructor(options) { | ||
@@ -32,3 +32,3 @@ super(); | ||
this.options.onCreated(request); | ||
return new apolloLink.Observable(observer => { | ||
return new client.Observable(observer => { | ||
return nextLink(operation).subscribe({ | ||
@@ -35,0 +35,0 @@ complete() { |
@@ -5,6 +5,6 @@ 'use strict'; | ||
var apolloLink = require('apollo-link'); | ||
var client = require('@apollo/client'); | ||
var graphql = require('graphql'); | ||
class MockLink extends apolloLink.ApolloLink { | ||
class MockLink extends client.ApolloLink { | ||
constructor(mock) { | ||
@@ -20,3 +20,3 @@ super(); | ||
request(operation) { | ||
return new apolloLink.Observable(obs => { | ||
return new client.Observable(obs => { | ||
const { | ||
@@ -23,0 +23,0 @@ mock |
@@ -1,8 +0,8 @@ | ||
import { ApolloReducerConfig } from 'apollo-cache-inmemory'; | ||
import { ApolloClient } from 'apollo-client'; | ||
import { ApolloClient, ApolloLink, ApolloReducerConfig, PossibleTypesMap } from '@apollo/client'; | ||
import { Operations } from './operations'; | ||
import { GraphQLMock, FindOptions } from './types'; | ||
export interface Options { | ||
unionOrIntersectionTypes?: any[]; | ||
possibleTypes?: PossibleTypesMap; | ||
cacheOptions?: ApolloReducerConfig; | ||
links?: ApolloLink[]; | ||
} | ||
@@ -18,3 +18,3 @@ interface Wrapper { | ||
private readonly mockLink; | ||
constructor(mock: GraphQLMock | undefined, { unionOrIntersectionTypes, cacheOptions }?: Options); | ||
constructor(mock: GraphQLMock | undefined, { possibleTypes, cacheOptions, links }?: Options); | ||
update(mock: GraphQLMock): void; | ||
@@ -21,0 +21,0 @@ resolveAll(options?: FindOptions): Promise<void>; |
@@ -1,2 +0,2 @@ | ||
import { ApolloLink, Observable, Operation, NextLink, FetchResult } from 'apollo-link'; | ||
import { ApolloLink, Observable, Operation, NextLink, FetchResult } from '@apollo/client'; | ||
import { MockRequest } from '../types'; | ||
@@ -3,0 +3,0 @@ interface Options { |
@@ -1,2 +0,2 @@ | ||
import { ApolloLink, Observable, Operation } from 'apollo-link'; | ||
import { ApolloLink, Observable, Operation } from '@apollo/client'; | ||
import { GraphQLMock } from '../types'; | ||
@@ -3,0 +3,0 @@ export declare class MockLink extends ApolloLink { |
@@ -1,2 +0,2 @@ | ||
import { Operation } from 'apollo-link'; | ||
import { Operation } from '@apollo/client'; | ||
export declare function assertIsGraphQL(graphQL: unknown, { expectation, isNot }: { | ||
@@ -3,0 +3,0 @@ expectation: string; |
@@ -1,2 +0,2 @@ | ||
import { Operation } from 'apollo-link'; | ||
import { Operation } from '@apollo/client'; | ||
import { FindOptions } from './types'; | ||
@@ -3,0 +3,0 @@ export declare class Operations { |
import { DocumentNode } from 'graphql'; | ||
import { GraphQLRequest, Operation } from 'apollo-link'; | ||
import { GraphQLRequest, Operation } from '@apollo/client'; | ||
export interface FindOptions { | ||
@@ -4,0 +4,0 @@ query?: DocumentNode | { |
{ | ||
"name": "@shopify/graphql-testing", | ||
"version": "0.0.0-snapshot-20220623162708", | ||
"version": "0.0.0-snapshot-20220706153926", | ||
"license": "MIT", | ||
@@ -34,5 +34,3 @@ "description": "Utilities to create mock GraphQL factories", | ||
"dependencies": { | ||
"apollo-cache-inmemory": ">=1.0.0 <2.0.0", | ||
"apollo-client": ">=2.0.0 <3.0.0", | ||
"apollo-link": ">=1.0.0 <2.0.0", | ||
"@apollo/client": "^3.5.8", | ||
"graphql": ">=14.5.0 <16.0.0", | ||
@@ -42,3 +40,3 @@ "jest-matcher-utils": "^26.6.2" | ||
"devDependencies": { | ||
"graphql-typed": "^2.0.0" | ||
"graphql-typed": "^3.0.0-a3-beta.1" | ||
}, | ||
@@ -45,0 +43,0 @@ "files": [ |
@@ -20,3 +20,3 @@ # `@shopify/graphql-testing` | ||
The default utility exported by this library is `createGraphQLFactory`. This factory accepts an optional options argument that allows you to pass a `unionOrIntersectionTypes` array and/ or additional `cacheOptions` that will be used to construct an Apollo in-memory cache. | ||
The default utility exported by this library is `createGraphQLFactory`. This factory accepts an optional options argument that allows you to pass a `unionOrIntersectionTypes` array and/ or additional `cacheOptions` that will be used to construct an Apollo in-memory cache and/ or `links` which can contain `ApolloLink`s that will be passed to the apollo client links. | ||
@@ -23,0 +23,0 @@ ```js |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3
57118
62
799
+ Added@apollo/client@^3.5.8
+ Added@apollo/client@3.12.3(transitive)
+ Added@graphql-typed-document-node/core@3.2.0(transitive)
+ Added@wry/caches@1.0.1(transitive)
+ Added@wry/context@0.7.4(transitive)
+ Added@wry/equality@0.5.7(transitive)
+ Added@wry/trie@0.5.0(transitive)
+ Addedgraphql-tag@2.12.6(transitive)
+ Addedhoist-non-react-statics@3.3.2(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedloose-envify@1.4.0(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedoptimism@0.18.1(transitive)
+ Addedprop-types@15.8.1(transitive)
+ Addedreact-is@16.13.1(transitive)
+ Addedrehackt@0.1.0(transitive)
+ Addedresponse-iterator@0.2.6(transitive)
+ Addedsymbol-observable@4.0.0(transitive)
+ Addedts-invariant@0.10.3(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedzen-observable-ts@1.2.5(transitive)
- Removedapollo-cache-inmemory@>=1.0.0 <2.0.0
- Removedapollo-client@>=2.0.0 <3.0.0
- Removedapollo-link@>=1.0.0 <2.0.0
- Removed@types/zen-observable@0.8.7(transitive)
- Removed@wry/context@0.4.4(transitive)
- Removed@wry/equality@0.1.11(transitive)
- Removedapollo-cache@1.3.5(transitive)
- Removedapollo-cache-inmemory@1.6.6(transitive)
- Removedapollo-client@2.6.10(transitive)
- Removedapollo-link@1.2.14(transitive)
- Removedapollo-utilities@1.3.4(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedoptimism@0.10.3(transitive)
- Removedsymbol-observable@1.2.0(transitive)
- Removedts-invariant@0.4.4(transitive)
- Removedtslib@1.14.1(transitive)
- Removedzen-observable-ts@0.8.21(transitive)