Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@shopify/graphql-testing

Package Overview
Dependencies
Maintainers
19
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/graphql-testing - npm Package Compare versions

Comparing version 0.0.0-snapshot-20221017173818 to 0.0.0-snapshot-20221110000311

42

build/cjs/graphql-controller.js

@@ -5,5 +5,3 @@ 'use strict';

var apolloLink = require('apollo-link');
var apolloCacheInmemory = require('apollo-cache-inmemory');
var apolloClient = require('apollo-client');
var client = require('@apollo/client');
var operations = require('./operations.js');

@@ -16,6 +14,4 @@ var utilities = require('./utilities.js');

constructor(mock, {
unionOrIntersectionTypes = [],
cacheOptions = {},
links = [],
assumeImmutableResults = false
links = []
} = {}) {

@@ -37,19 +33,9 @@ this.client = void 0;

const cache = new apolloCacheInmemory.InMemoryCache({
fragmentMatcher: new apolloCacheInmemory.IntrospectionFragmentMatcher({
introspectionQueryResultData: {
__schema: {
types: unionOrIntersectionTypes
}
}
}),
...cacheOptions
});
const cache = new client.InMemoryCache(cacheOptions);
this.mockLink = new mocks.MockLink(mock || defaultGraphQLMock);
const link = apolloLink.ApolloLink.from([...links, new inflight.InflightLink({
const link = client.ApolloLink.from([...links, new inflight.InflightLink({
onCreated: this.handleCreate,
onResolved: this.handleResolve
}), this.mockLink]);
this.client = new apolloClient.ApolloClient({
assumeImmutableResults,
this.client = new client.ApolloClient({
link,

@@ -68,7 +54,11 @@ cache

async resolveFetchMore() {
await this.withWrapper(async () => {
await this.client.queryManager.broadcastQueries();
});
}
async resolveAll(options = {}) {
const finalOperationName = utilities.operationNameFromFindOptions(options);
await this.wrappers.reduce((perform, wrapper) => {
return () => wrapper(perform);
}, async () => {
await this.withWrapper(async () => {
const allPendingRequests = Array.from(this.pendingRequests);

@@ -83,2 +73,10 @@ const matchingRequests = finalOperationName ? allPendingRequests.filter(({

}) => resolve()));
});
}
async withWrapper(cb) {
await this.wrappers.reduce((perform, wrapper) => {
return () => wrapper(perform);
}, async () => {
await cb();
})();

@@ -85,0 +83,0 @@ }

@@ -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,11 +0,7 @@

import { ApolloLink } from 'apollo-link';
import { InMemoryCacheConfig } from 'apollo-cache-inmemory';
import { ApolloClient } from 'apollo-client';
import { ApolloClient, ApolloLink, InMemoryCacheConfig } from '@apollo/client';
import { Operations } from './operations';
import { GraphQLMock, FindOptions } from './types';
export interface Options {
unionOrIntersectionTypes?: any[];
cacheOptions?: InMemoryCacheConfig;
links?: ApolloLink[];
assumeImmutableResults?: boolean;
}

@@ -21,5 +17,7 @@ interface Wrapper {

private readonly mockLink;
constructor(mock: GraphQLMock | undefined, { unionOrIntersectionTypes, cacheOptions, links, assumeImmutableResults, }?: Options);
constructor(mock: GraphQLMock | undefined, { cacheOptions, links }?: Options);
update(mock: GraphQLMock): void;
resolveFetchMore(): Promise<void>;
resolveAll(options?: FindOptions): Promise<void>;
withWrapper(cb: () => Promise<void>): Promise<void>;
wrap(wrapper: Wrapper): void;

@@ -26,0 +24,0 @@ private handleCreate;

@@ -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-20221017173818",
"version": "0.0.0-snapshot-20221110000311",
"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",

@@ -39,0 +37,0 @@ "jest-matcher-utils": "^26.6.2"

@@ -20,7 +20,9 @@ # `@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 and/ or `links` which can contain `ApolloLink`s that will be passed to the apollo client links.
The default utility exported by this library is `createGraphQLFactory`. This factory accepts an optional options argument that allows you to pass a `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.
```js
const createGraphQL = createGraphQLFactory({
unionOrIntersectionTypes: [],
cacheOptions: {
possibleTypes: {},
},
});

@@ -27,0 +29,0 @@ ```

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc