Skip to content

Commit

Permalink
refactor: rename internal type
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonkuhrt committed Apr 5, 2023
1 parent 82e0050 commit 8467a26
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ To do that, pass a function that returns the headers to the `headers` property w
import { GraphQLClient } from 'graphql-request'

const client = new GraphQLClient(endpoint, {
headers: () => ({ 'X-Sent-At-Time': Date.now() }),
headers: () => ({ 'X-Sent-At-Time': Date.now().toString() }),
})

const query = gql`
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {
GraphQLClientResponse,
HTTPMethodInput,
JsonSerializer,
MaybeFunction,
MaybeLazy,
RequestConfig,
RequestMiddleware,
VariablesAndRequestHeadersArgs,
Expand Down Expand Up @@ -628,7 +628,7 @@ const getResult = async (
}
}

const callOrIdentity = <T>(value: MaybeFunction<T>) => {
const callOrIdentity = <T>(value: MaybeLazy<T>) => {
return typeof value === `function` ? (value as () => T)() : value
}

Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class ClientError extends Error {
}
}

export type MaybeFunction<T> = T | (() => T)
export type MaybeLazy<T> = T | (() => T)

export type RequestDocument = string | DocumentNode

Expand All @@ -94,7 +94,7 @@ export type HTTPMethodInput = 'GET' | 'POST' | 'get' | 'post'
export interface RequestConfig extends Omit<RequestInit, 'headers' | 'method'>, AdditionalRequestOptions {
fetch?: Fetch
method?: HTTPMethodInput
headers?: MaybeFunction<GraphQLClientRequestHeaders>
headers?: MaybeLazy<GraphQLClientRequestHeaders>
requestMiddleware?: RequestMiddleware
responseMiddleware?: (response: GraphQLClientResponse<unknown> | Error) => void
jsonSerializer?: JsonSerializer
Expand Down

0 comments on commit 8467a26

Please sign in to comment.