Skip to content
Open
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
- npm-install
- run:
name: TypeScript
command: npm run build
command: npm run build -w @apollo/explorer-helpers && npm run build

build-latest-umd-explorer:
executor: node
Expand Down
6 changes: 5 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
"endOfLine": "auto"
},
"workspaces": [
"packages/explorer-helpers",
"packages/explorer",
"packages/sandbox",
"packages/explorer-helpers"
"packages/sandbox"
],
"devDependencies": {
"@babel/core": "^7.18.5",
Expand Down
1 change: 1 addition & 0 deletions packages/explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
}
},
"dependencies": {
"@apollo/explorer-helpers": "^0.1.4",
"@types/whatwg-mimetype": "^3.0.0",
"graphql-ws": "^5.9.0",
"subscriptions-transport-ws": "^0.11.0",
Expand Down
102 changes: 0 additions & 102 deletions packages/explorer/src/helpers/constructMultipartForm.ts

This file was deleted.

45 changes: 26 additions & 19 deletions packages/explorer/src/helpers/postMessageRelayHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ import {
EXPLORER_LISTENING_FOR_SCHEMA,
} from './constants';
import MIMEType from 'whatwg-mimetype';
import { readMultipartWebStream } from './readMultipartWebStream';
import type { JSONObject, JSONValue } from './types';
import type { ObjMap } from 'graphql/jsutils/ObjMap';
import type {
GraphQLSubscriptionLibrary,
HTTPMultipartClient,
} from './subscriptionPostMessageRelayHelpers';
import { constructMultipartForm, FileVariable } from './constructMultipartForm';
import {
readMultipartWebStream,
constructMultipartForm,
FileVariable,
} from '@apollo/explorer-helpers';

export type HandleRequest = (
endpointUrl: string,
Expand Down Expand Up @@ -89,21 +92,6 @@ type ExplorerResponse = ResponseData & {
size?: number;
};

// https://apollographql.quip.com/mkWRAJfuxa7L/Multipart-subscriptions-protocol-spec
export interface MultipartSubscriptionResponse {
data: {
errors?: Array<GraphQLError>;
payload:
| (ResponseData & {
error?: { message: string; stack?: string };
})
| null;
};
headers?: Record<string, string> | Record<string, string>[];
size: number;
status?: number;
}

export type ExplorerSubscriptionResponse =
// websocket response
| {
Expand All @@ -112,7 +100,20 @@ export type ExplorerSubscriptionResponse =
errors?: GraphQLError[];
}
// http multipart response options below
| MultipartSubscriptionResponse
// https://apollographql.quip.com/mkWRAJfuxa7L/Multipart-subscriptions-protocol-spec
| {
data: {
errors?: Array<GraphQLError>;
payload:
| (ResponseData & {
error?: { message: string; stack?: string };
})
| null;
};
headers?: Record<string, string> | Record<string, string>[];
size: number;
status?: number;
}
| {
data: null;
// this only exists in the PM MultipartSubscriptionResponse
Expand Down Expand Up @@ -248,9 +249,15 @@ export async function executeOperation({
};
let promise: Promise<Response>;
if (fileVariables && fileVariables.length > 0) {
// the types expected by the shared constructMultipartForm expect
// variables to be defined or null
const requestBodyWithDefaultNullVariables = {
...requestBody,
variables: requestBody.variables ?? null,
};
const form = await constructMultipartForm({
fileVariables,
requestBody,
requestBody: requestBodyWithDefaultNullVariables,
});

promise = handleRequest(endpointUrl, {
Expand Down
Loading