From bb48aeecec25e054070d459d24c16bb2c4ad2699 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Thu, 5 Sep 2024 10:59:13 -0400 Subject: [PATCH] refactor: rec accept value to gqlhttp lib --- src/layers/5_core/core.ts | 9 ++------- src/lib/graphqlHTTP.ts | 6 ++++++ src/lib/http.ts | 5 +---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/layers/5_core/core.ts b/src/layers/5_core/core.ts index 04fa62c7b..dee8214e5 100644 --- a/src/layers/5_core/core.ts +++ b/src/layers/5_core/core.ts @@ -2,13 +2,8 @@ import type { DocumentNode, ExecutionResult, GraphQLSchema } from 'graphql' import { print } from 'graphql' import { Anyware } from '../../lib/anyware/__.js' import { type StandardScalarVariables } from '../../lib/graphql.js' -import { parseExecutionResult } from '../../lib/graphqlHTTP.js' -import { - CONTENT_TYPE_GQL, - CONTENT_TYPE_GQL_OVER_HTTP_REC, - CONTENT_TYPE_JSON, - mergeHeadersInit, -} from '../../lib/http.js' +import { CONTENT_TYPE_GQL_OVER_HTTP_REC, parseExecutionResult } from '../../lib/graphqlHTTP.js' +import { CONTENT_TYPE_JSON, mergeHeadersInit } from '../../lib/http.js' import { casesExhausted } from '../../lib/prelude.js' import { execute } from '../0_functions/execute.js' import type { Schema } from '../1_Schema/__.js' diff --git a/src/lib/graphqlHTTP.ts b/src/lib/graphqlHTTP.ts index 750499c4e..af052ed8e 100644 --- a/src/lib/graphqlHTTP.ts +++ b/src/lib/graphqlHTTP.ts @@ -1,6 +1,7 @@ import type { GraphQLFormattedError } from 'graphql' import { type ExecutionResult, GraphQLError } from 'graphql' import type { StandardScalarVariables } from './graphql.js' +import { CONTENT_TYPE_GQL, CONTENT_TYPE_JSON } from './http.js' import { isPlainObject } from './prelude.js' export type ExecutionInput = { @@ -51,3 +52,8 @@ export const parseExecutionResult = (result: unknown): ExecutionResult => { extensions, } } + +/** + * @see https://graphql.github.io/graphql-over-http/draft/#sec-Legacy-Watershed + */ +export const CONTENT_TYPE_GQL_OVER_HTTP_REC = `${CONTENT_TYPE_GQL}; charset=utf-8, ${CONTENT_TYPE_JSON}; charset=utf-8` diff --git a/src/lib/http.ts b/src/lib/http.ts index ed0422d0b..be3b22ff2 100644 --- a/src/lib/http.ts +++ b/src/lib/http.ts @@ -2,10 +2,7 @@ export const ACCEPT_HEADER = `Accept` export const CONTENT_TYPE_HEADER = `Content-Type` export const CONTENT_TYPE_JSON = `application/json` export const CONTENT_TYPE_GQL = `application/graphql-response+json` -/** - * @see https://graphql.github.io/graphql-over-http/draft/#sec-Legacy-Watershed - */ -export const CONTENT_TYPE_GQL_OVER_HTTP_REC = `${CONTENT_TYPE_GQL}; charset=utf-8, ${CONTENT_TYPE_JSON}; charset=utf-8` + export const statusCodes = { success: 200, }