Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gh 924 #1132

Closed
wants to merge 5 commits into from
Closed

Gh 924 #1132

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/generate/addResolveFunctionsToSchema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SchemaError } from '.';
import SchemaError from './SchemaError';

import {
GraphQLField,
Expand All @@ -17,7 +17,8 @@ import {
IAddResolveFunctionsToSchemaOptions,
} from '../Interfaces';
import { applySchemaTransforms } from '../transforms/transforms';
import { checkForResolveTypeResolver, extendResolversFromInterfaces } from '.';
import checkForResolveTypeResolver from './checkForResolveTypeResolver';
import extendResolversFromInterfaces from './extendResolversFromInterfaces';
import ConvertEnumValues from '../transforms/ConvertEnumValues';

function addResolveFunctionsToSchema(
Expand Down
3 changes: 2 additions & 1 deletion src/generate/assertResolveFunctionsPresent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
} from 'graphql';
import { IResolverValidationOptions } from '../Interfaces';

import { forEachField, SchemaError } from '.';
import SchemaError from './SchemaError';
import forEachField from './forEachField';

function assertResolveFunctionsPresent(
schema: GraphQLSchema,
Expand Down
2 changes: 1 addition & 1 deletion src/generate/attachConnectorsToContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { deprecated } from 'deprecated-decorator';

import { IConnectors, IConnector, IConnectorCls } from '../Interfaces';

import { addSchemaLevelResolveFunction } from '.';
import addSchemaLevelResolveFunction from './addSchemaLevelResolveFunction';

// takes a GraphQL-JS schema and an object of connectors, then attaches
// the connectors to the context by wrapping each query or mutation resolve
Expand Down
8 changes: 3 additions & 5 deletions src/generate/buildSchemaFromTypeDefinitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import {
} from 'graphql';
import { ITypeDefinitions, GraphQLParseOptions } from '../Interfaces';

import {
extractExtensionDefinitions,
concatenateTypeDefs,
SchemaError,
} from '.';
import SchemaError from './SchemaError';
import extractExtensionDefinitions from './extractExtensionDefinitions';
import concatenateTypeDefs from './concatenateTypeDefs';

function buildSchemaFromTypeDefinitions(
typeDefinitions: ITypeDefinitions,
Expand Down
2 changes: 1 addition & 1 deletion src/generate/checkForResolveTypeResolver.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { GraphQLInterfaceType, GraphQLUnionType, GraphQLSchema } from 'graphql';

import { SchemaError } from '.';
import SchemaError from './SchemaError';

// If we have any union or interface types throw if no there is no resolveType or isTypeOf resolvers
function checkForResolveTypeResolver(
Expand Down
2 changes: 1 addition & 1 deletion src/generate/concatenateTypeDefs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { print, DocumentNode } from 'graphql';
import { ITypedef } from '../Interfaces';

import { SchemaError } from '.';
import SchemaError from './SchemaError';

function concatenateTypeDefs(
typeDefinitionsAry: ITypedef[],
Expand Down
36 changes: 19 additions & 17 deletions src/test/testMakeRemoteExecutableSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ describe('remote subscriptions', () => {
`);

let notificationCnt = 0;
subscribe(schema, subscription).then(results =>
subscribe(schema, subscription).then(results => {
forAwaitEach(results as AsyncIterable<ExecutionResult>, (result: ExecutionResult) => {
expect(result).to.have.property('data');
expect(result.data).to.deep.equal(mockNotification);
!notificationCnt++ ? done() : null;
}),
);

subscriptionPubSub.publish(subscriptionPubSubTrigger, mockNotification);
});
}).then(() => {
subscriptionPubSub.publish(subscriptionPubSubTrigger, mockNotification);
});
});

it('should work without triggering multiple times per notification', done => {
Expand All @@ -59,27 +59,29 @@ describe('remote subscriptions', () => {
`);

let notificationCnt = 0;
subscribe(schema, subscription).then(results =>
const sub1 = subscribe(schema, subscription).then(results => {
forAwaitEach(results as AsyncIterable<ExecutionResult>, (result: ExecutionResult) => {
expect(result).to.have.property('data');
expect(result.data).to.deep.equal(mockNotification);
notificationCnt++;
}),
);
});
});

subscribe(schema, subscription).then(results =>
const sub2 = subscribe(schema, subscription).then(results => {
forAwaitEach(results as AsyncIterable<ExecutionResult>, (result: ExecutionResult) => {
expect(result).to.have.property('data');
expect(result.data).to.deep.equal(mockNotification);
}),
);
});
});

subscriptionPubSub.publish(subscriptionPubSubTrigger, mockNotification);
subscriptionPubSub.publish(subscriptionPubSubTrigger, mockNotification);
Promise.all([sub1, sub2]).then(() => {
subscriptionPubSub.publish(subscriptionPubSubTrigger, mockNotification);
subscriptionPubSub.publish(subscriptionPubSubTrigger, mockNotification);

setTimeout(() => {
expect(notificationCnt).to.eq(2);
done();
}, 0);
setTimeout(() => {
expect(notificationCnt).to.eq(2);
done();
}, 0);
});
});
});
14 changes: 6 additions & 8 deletions src/test/testMergeSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,9 @@ bookingById(id: "b1") {
!notificationCnt++ ? done() : null;
},
).catch(done);
})
.catch(done);

subscriptionPubSub.publish(subscriptionPubSubTrigger, mockNotification);
}).then(() => {
subscriptionPubSub.publish(subscriptionPubSubTrigger, mockNotification);
}).catch(done);
});

it('subscription errors are working correctly in merged schema', done => {
Expand Down Expand Up @@ -793,10 +792,9 @@ bookingById(id: "b1") {
!notificationCnt++ ? done() : null;
},
).catch(done);
})
.catch(done);

subscriptionPubSub.publish(subscriptionPubSubTrigger, mockNotification);
}).then(() => {
subscriptionPubSub.publish(subscriptionPubSubTrigger, mockNotification);
}).catch(done);
});

it('links in queries', async () => {
Expand Down
6 changes: 3 additions & 3 deletions src/test/testResolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ describe('Resolve', () => {
done(new Error('Too many subscription fired'));
},
).catch(done);
})
.catch(done);
}).then(() => {
pubsub.publish('printRootChannel', { printRoot: subscriptionRoot });
}).catch(done);
});

pubsub.publish('printRootChannel', { printRoot: subscriptionRoot });

firstSubsTriggered
.then(() =>
Expand Down