Skip to content

Commit

Permalink
fix(grpahql_transport_ws): add picking sub-protocol for `graphql-tran…
Browse files Browse the repository at this point in the history
…sport-ws`
  • Loading branch information
TomokiMiyauci committed Aug 9, 2022
1 parent 52edba7 commit ec6968b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
15 changes: 4 additions & 11 deletions deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,20 @@ export {
validate,
validateSchema,
} from "https://esm.sh/[email protected]";
export { Status } from "https://deno.land/std@0.150.0/http/http_status.ts";
export { Status } from "https://deno.land/std@0.151.0/http/http_status.ts";
export {
createHttpError,
HttpError,
} from "https://deno.land/std@0.150.0/http/http_errors.ts";
export { createHandler } from "https://deno.land/x/[email protected].1/mod.ts";
} from "https://deno.land/std@0.151.0/http/http_errors.ts";
export { createHandler } from "https://deno.land/x/[email protected].3/mod.ts";
export {
type GraphQLParameters,
parseGraphQLParameters,
} from "https://deno.land/x/[email protected]/mod.ts";
export { parseMessage as parseServerMessage } from "https://deno.land/x/[email protected]/client/mod.ts";
export {
MessageType,
type NextMessage,
PrivateStatus,
PROTOCOL,
type SubscribeMessage,
} from "https://deno.land/x/[email protected]/mod.ts";
export {
createClient,
createServer,
PROTOCOL,
} from "https://deno.land/x/[email protected]/mod.ts";

// deno-lint-ignore no-explicit-any
Expand Down
7 changes: 7 additions & 0 deletions graphql_transport_ws/handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
createHandler as createWsHandler,
createServer,
PROTOCOL,
validateSchema,
} from "../deps.ts";
import { GraphQLExecutionArgs } from "../types.ts";
Expand Down Expand Up @@ -44,6 +45,12 @@ export default function createHandler(
{ url: socket, schema: params.schema },
params,
);
}, {
protocol: (protocols) => {
if (protocols.includes(PROTOCOL)) {
return PROTOCOL;
}
},
});

return handler;
Expand Down

0 comments on commit ec6968b

Please sign in to comment.