Skip to content

Commit

Permalink
Move reset() to a void return type in the internal remote API
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pimterry committed Jul 7, 2021
1 parent a977eca commit 07a4d64
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/client/mockttp-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,10 @@ export class MockttpClient extends AbstractMockttp implements Mockttp {
throw new Error("Client-side debug info not implemented.");
}

reset = async (): Promise<boolean> => {
return (await this.queryMockServer<boolean>(
reset = async (): Promise<void> => {
return (await this.queryMockServer<void>(
`mutation Reset {
reset
reset
}`
));
}
Expand Down
3 changes: 2 additions & 1 deletion src/standalone/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Mutation {
addWebSocketRules(input: [WebSocketMockRule!]!): [MockedEndpoint!]!
setWebSocketRules(input: [WebSocketMockRule!]!): [MockedEndpoint!]!

reset: Boolean!
reset: Void
}

type Subscription {
Expand Down Expand Up @@ -121,6 +121,7 @@ type Response {
}

scalar Any
scalar Void
scalar Json
scalar Buffer
scalar RequestMatcher
Expand Down
13 changes: 9 additions & 4 deletions src/standalone/standalone-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -246,10 +254,7 @@ export function buildStandaloneModel(mockServer: MockttpServer, stream: Duplex):
));
},

reset: () => {
mockServer.reset();
return true;
}
reset: () => mockServer.reset()
},

Subscription: {
Expand Down

0 comments on commit 07a4d64

Please sign in to comment.