diff --git a/packages/hoppscotch-common/src/components.d.ts b/packages/hoppscotch-common/src/components.d.ts index be3cfcb7..22747b90 100644 --- a/packages/hoppscotch-common/src/components.d.ts +++ b/packages/hoppscotch-common/src/components.d.ts @@ -111,6 +111,7 @@ declare module 'vue' { GraphqlRequestOptions: typeof import('./components/graphql/RequestOptions.vue')['default'] GraphqlRequestTab: typeof import('./components/graphql/RequestTab.vue')['default'] GraphqlResponse: typeof import('./components/graphql/Response.vue')['default'] + GraphqlResponseMeta: typeof import('./components/graphql/ResponseMeta.vue')['default'] GraphqlSchemaDocumentation: typeof import('./components/graphql/SchemaDocumentation.vue')['default'] GraphqlSchemaSearch: typeof import('./components/graphql/SchemaSearch.vue')['default'] GraphqlSidebar: typeof import('./components/graphql/Sidebar.vue')['default'] diff --git a/packages/hoppscotch-common/src/components/graphql/Response.vue b/packages/hoppscotch-common/src/components/graphql/Response.vue index 81d18750..a3be45c9 100644 --- a/packages/hoppscotch-common/src/components/graphql/Response.vue +++ b/packages/hoppscotch-common/src/components/graphql/Response.vue @@ -1,5 +1,6 @@ diff --git a/packages/hoppscotch-common/src/components/graphql/ResponseMeta.vue b/packages/hoppscotch-common/src/components/graphql/ResponseMeta.vue new file mode 100644 index 00000000..a0f43e87 --- /dev/null +++ b/packages/hoppscotch-common/src/components/graphql/ResponseMeta.vue @@ -0,0 +1,163 @@ + + + diff --git a/packages/hoppscotch-common/src/helpers/graphql/connection.ts b/packages/hoppscotch-common/src/helpers/graphql/connection.ts index 5286a75d..b5036d2d 100644 --- a/packages/hoppscotch-common/src/helpers/graphql/connection.ts +++ b/packages/hoppscotch-common/src/helpers/graphql/connection.ts @@ -61,6 +61,15 @@ export type GQLResponseEvent = operationType: OperationType data: string rawQuery?: RunQueryOptions + document?: { + type: string + statusCode: number + statusText: string + meta: { + responseSize: number + responseDuration: number + } + } } | { type: "error" @@ -456,7 +465,21 @@ export const runGQLOperation = async (options: RunQueryOptions) => { throw new Error(parsedResponse.error.message) } - gqlMessageEvent.value = parsedResponse + const timeStart = Date.now() + const timeEnd = Date.now() + + gqlMessageEvent.value = { + ...parsedResponse, + document: { + type: "success", + statusCode: relayResponse.status, + statusText: relayResponse.statusText, + meta: { + responseSize: relayResponse.body.body.byteLength, + responseDuration: timeEnd - timeStart, + }, + }, + } addQueryToHistory(options, parsedResponse.data)