fix: remove useless parameter
parent
c952819067
commit
298ed2097a
|
|
@ -2,26 +2,16 @@ import useSWR, { SWRResponse, SWRConfiguration } from 'swr'
|
||||||
import { request } from '@/lib/tabby-gql-client'
|
import { request } from '@/lib/tabby-gql-client'
|
||||||
import { Variables } from 'graphql-request'
|
import { Variables } from 'graphql-request'
|
||||||
import { TypedDocumentNode } from '@graphql-typed-document-node/core'
|
import { TypedDocumentNode } from '@graphql-typed-document-node/core'
|
||||||
import { ASTNode, Kind, OperationDefinitionNode } from 'graphql'
|
|
||||||
|
|
||||||
const isOperationDefinition = (def: ASTNode): def is OperationDefinitionNode =>
|
|
||||||
def.kind === Kind.OPERATION_DEFINITION
|
|
||||||
|
|
||||||
function useGraphQL<TResult, TVariables extends Variables | undefined>(
|
function useGraphQL<TResult, TVariables extends Variables | undefined>(
|
||||||
document: TypedDocumentNode<TResult, TVariables>,
|
document: TypedDocumentNode<TResult, TVariables>,
|
||||||
variables?: TVariables,
|
variables?: TVariables,
|
||||||
options?: SWRConfiguration<TResult>
|
swrConfiguration?: SWRConfiguration<TResult>
|
||||||
): SWRResponse<TResult> {
|
): SWRResponse<TResult> {
|
||||||
return useSWR(
|
return useSWR(
|
||||||
[
|
[document, variables],
|
||||||
document.definitions.find(isOperationDefinition)?.name?.value,
|
([document, variables]) => request({ document, variables }),
|
||||||
document,
|
swrConfiguration
|
||||||
variables
|
|
||||||
],
|
|
||||||
([_key, document, variables]) => {
|
|
||||||
return request({ document, variables })
|
|
||||||
},
|
|
||||||
options
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue