From 07a4d64e123a269b0117534f804be2e25dae1bf4 Mon Sep 17 00:00:00 2001 From: Tim Perry Date: Wed, 7 Jul 2021 13:21:56 +0200 Subject: [PATCH] Move reset() to a void return type in the internal remote API This replaces an unchecked (and _always_ true) return type that was previously used. This is not a breaking change, as the docs and the return type of the main Mockttp interface itself are all specified as void already. --- src/client/mockttp-client.ts | 6 +++--- src/standalone/schema.gql | 3 ++- src/standalone/standalone-model.ts | 13 +++++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/client/mockttp-client.ts b/src/client/mockttp-client.ts index db49067f6..f34e39f95 100644 --- a/src/client/mockttp-client.ts +++ b/src/client/mockttp-client.ts @@ -401,10 +401,10 @@ export class MockttpClient extends AbstractMockttp implements Mockttp { throw new Error("Client-side debug info not implemented."); } - reset = async (): Promise => { - return (await this.queryMockServer( + reset = async (): Promise => { + return (await this.queryMockServer( `mutation Reset { - reset + reset }` )); } diff --git a/src/standalone/schema.gql b/src/standalone/schema.gql index 26fecd31c..c1bf86ad1 100644 --- a/src/standalone/schema.gql +++ b/src/standalone/schema.gql @@ -14,7 +14,7 @@ type Mutation { addWebSocketRules(input: [WebSocketMockRule!]!): [MockedEndpoint!]! setWebSocketRules(input: [WebSocketMockRule!]!): [MockedEndpoint!]! - reset: Boolean! + reset: Void } type Subscription { @@ -121,6 +121,7 @@ type Response { } scalar Any +scalar Void scalar Json scalar Buffer scalar RequestMatcher diff --git a/src/standalone/standalone-model.ts b/src/standalone/standalone-model.ts index 959009eea..eaeb41e20 100644 --- a/src/standalone/standalone-model.ts +++ b/src/standalone/standalone-model.ts @@ -141,6 +141,14 @@ const ScalarResolvers = { parseLiteral: parseAnyAst }), + Void: new GraphQLScalarType({ + name: 'Void', + description: 'Nothing at all', + serialize: (value: any) => null, + parseValue: (input: string): any => null, + parseLiteral: (): any => { throw new Error('Void literals are not supported') } + }), + Buffer: new GraphQLScalarType({ name: 'Buffer', description: 'A buffer', @@ -246,10 +254,7 @@ export function buildStandaloneModel(mockServer: MockttpServer, stream: Duplex): )); }, - reset: () => { - mockServer.reset(); - return true; - } + reset: () => mockServer.reset() }, Subscription: {