diff --git a/docs/README.md b/docs/README.md index db029582..5bd0197a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,8 +13,8 @@ graphql-http - [Client](interfaces/Client.md) - [ClientOptions](interfaces/ClientOptions.md) - [HandlerOptions](interfaces/HandlerOptions.md) -- [Headers](interfaces/Headers.md) - [Request](interfaces/Request.md) +- [RequestHeaders](interfaces/RequestHeaders.md) - [RequestParams](interfaces/RequestParams.md) - [ResponseInit](interfaces/ResponseInit.md) - [Sink](interfaces/Sink.md) @@ -25,6 +25,7 @@ graphql-http - [Handler](README.md#handler) - [Response](README.md#response) - [ResponseBody](README.md#responsebody) +- [ResponseHeaders](README.md#responseheaders) ### Functions @@ -71,6 +72,14 @@ to be coerced to the server implementation in use. ___ +### ResponseHeaders + +Ƭ **ResponseHeaders**: { `accept?`: `string` ; `allow?`: `string` ; `content-type?`: `string` } & `Record`<`string`, `string`\> + +The response headers that get returned from graphql-http. + +___ + ### isResponse ▸ **isResponse**(`val`): val is Response diff --git a/docs/interfaces/Request.md b/docs/interfaces/Request.md index f29be36b..494f8fed 100644 --- a/docs/interfaces/Request.md +++ b/docs/interfaces/Request.md @@ -31,7 +31,7 @@ ___ ### headers -• `Readonly` **headers**: [`Headers`](Headers.md) +• `Readonly` **headers**: [`RequestHeaders`](RequestHeaders.md) ___ diff --git a/docs/interfaces/Headers.md b/docs/interfaces/RequestHeaders.md similarity index 62% rename from docs/interfaces/Headers.md rename to docs/interfaces/RequestHeaders.md index 9a2f9845..67bb8f80 100644 --- a/docs/interfaces/Headers.md +++ b/docs/interfaces/RequestHeaders.md @@ -1,8 +1,8 @@ -[graphql-http](../README.md) / Headers +[graphql-http](../README.md) / RequestHeaders -# Interface: Headers +# Interface: RequestHeaders -Concrete interface that the headers map should implement. +The incoming request headers the implementing server should provide. ## Indexable @@ -12,10 +12,10 @@ Concrete interface that the headers map should implement. ### Properties -- [accept](Headers.md#accept) -- [allow](Headers.md#allow) -- [content-type](Headers.md#content-type) -- [set-cookie](Headers.md#set-cookie) +- [accept](RequestHeaders.md#accept) +- [allow](RequestHeaders.md#allow) +- [content-type](RequestHeaders.md#content-type) +- [set-cookie](RequestHeaders.md#set-cookie) ## Properties diff --git a/docs/interfaces/ResponseInit.md b/docs/interfaces/ResponseInit.md index 68b1ce2d..41c1aa23 100644 --- a/docs/interfaces/ResponseInit.md +++ b/docs/interfaces/ResponseInit.md @@ -17,7 +17,7 @@ Server agnostic response options (ex. status and headers) returned from ### headers -• `Optional` `Readonly` **headers**: [`Headers`](Headers.md) +• `Optional` `Readonly` **headers**: [`ResponseHeaders`](../README.md#responseheaders) ___ diff --git a/src/__tests__/client.ts b/src/__tests__/client.ts index 8a0ede8f..efe58359 100644 --- a/src/__tests__/client.ts +++ b/src/__tests__/client.ts @@ -1,11 +1,11 @@ import fetch from 'node-fetch'; -import { Headers } from '../common'; +import { RequestHeaders } from '../common'; import { createClient, NetworkError } from '../client'; import { startTServer } from './utils/tserver'; import { texecute } from './utils/texecute'; it('should use the provided headers', async () => { - let headers: Headers = {}; + let headers: RequestHeaders = {}; const server = startTServer({ onSubscribe: (req) => { headers = req.headers; diff --git a/src/common.ts b/src/common.ts index e0be4cc5..0d2ab414 100644 --- a/src/common.ts +++ b/src/common.ts @@ -7,11 +7,11 @@ import { isObject } from './utils'; /** - * Concrete interface that the headers map should implement. + * The incoming request headers the implementing server should provide. * * @category Common */ -export interface Headers { +export interface RequestHeaders { accept?: string | undefined; allow?: string | undefined; 'content-type'?: string | undefined; @@ -33,7 +33,7 @@ export interface Headers { export interface Request { readonly method: string; readonly url: string; - readonly headers: Headers; + readonly headers: RequestHeaders; readonly body: string | Record | null; /** * The raw request itself from the implementing server. @@ -58,6 +58,17 @@ export interface RequestParams { extensions?: Record | undefined; } +/** + * The response headers that get returned from graphql-http. + * + * @category Common + */ +export type ResponseHeaders = { + accept?: string; + allow?: string; + 'content-type'?: string; +} & Record; + /** * Server agnostic response body returned from `graphql-http` needing * to be coerced to the server implementation in use. @@ -75,7 +86,7 @@ export type ResponseBody = string; export interface ResponseInit { readonly status: number; readonly statusText?: string; - readonly headers?: Headers; + readonly headers?: ResponseHeaders; } /**