dotansimha/graphql-code-generator

Pass the client in the codgen.yml, when using graphql-request with react-query

开放

#5,156 创建于 2020年12月1日

 (1 条评论) (2 个反应) (0 位负责人)TypeScript (1,295 个派生)batch import
help wantedkind/enhancementplugins

仓库指标

星标
 (10,341 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Is your feature request related to a problem? Please describe.

When using react-query plugin with graphql-request, it requires you to always pass the client in the generated query like in the provided example:

import { useMyQuery } from './generated';
import { client } from './my-graphql-request-client';

export const MyComponent = () => {
  const { status, data, error, isFetching } = useMyQuery(client, {});
};

Describe the solution you'd like It would be cool to pass the client in the codegen.yml, like for the example you do with the fetch option:

plugins:
  - add:
     content: "import { endpointUrl, fetchParams } from './my-config';"
  - typescript
  - typescript-operations
  - typescript-react-query
config:
  fetcher:
    endpoint: 'endpointUrl'
    fetchParams: 'fetchParams'

贡献者指南