Skip to content

Commit

Permalink
fix: export "HttpRequestHandler" and "GraphQLRequestHandler" types (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Jan 17, 2024
1 parent d6f7779 commit ca423d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ export type {
RequestQuery,
HttpRequestParsedResult,
} from './handlers/HttpHandler'
export type { HttpResponseResolver } from './http'
export type { HttpRequestHandler, HttpResponseResolver } from './http'

export type {
GraphQLQuery,
GraphQLVariables,
GraphQLRequestBody,
GraphQLJsonRequestBody,
} from './handlers/GraphQLHandler'
export type { GraphQLResponseResolver } from './graphql'
export type { GraphQLRequestHandler, GraphQLResponseResolver } from './graphql'

export type { Path, PathParams, Match } from './utils/matching/matchRequestUrl'
export type { ParsedGraphQLRequest } from './utils/internal/parseGraphQLRequest'
Expand Down
23 changes: 16 additions & 7 deletions test/typings/custom-handler.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import { http, HttpHandler, GraphQLHandler, graphql } from 'msw'
import { http, HttpRequestHandler, GraphQLRequestHandler, graphql } from 'msw'
import { setupWorker } from 'msw/browser'
import { setupServer } from 'msw/node'

function generateHttpHandler(): HttpHandler {
return http.get('/user', () => {})
const generateHttpHandler: HttpRequestHandler = (path, resolver, options) => {
return http.get(path, resolver, options)
}

function generateGraphQLHandler(): GraphQLHandler {
return graphql.query('GetUser', () => {})
const generateGraphQLHandler: GraphQLRequestHandler = (
operationName,
resolver,
) => {
return graphql.query(operationName, resolver)
}

setupWorker(generateHttpHandler(), generateGraphQLHandler())
setupServer(generateHttpHandler(), generateGraphQLHandler())
setupWorker(
generateHttpHandler('/', () => {}),
generateGraphQLHandler('GetResource', () => {}),
)
setupServer(
generateHttpHandler('/', () => {}),
generateGraphQLHandler('GetResource', () => {}),
)

0 comments on commit ca423d9

Please sign in to comment.