dotansimha / graphql-code-generator-community

MIT License
119 stars 156 forks source link

typescript-react-query custom fetcher not using correct import with near-operation-file #829

Open dohomi opened 2 months ago

dohomi commented 2 months ago

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

Using near-oparation-file has a wrong import using custom fetcher.

Describe the solution you'd like

The path should be correct.

Describe alternatives you've considered

Using typescript alias path fixes it but might be an easier fix within the plugin

dohomi commented 2 months ago
    generates: {
        "./src/utils/__generated__/types.ts": {
            documents: ['src/**/*.gql'],
            plugins: ["typescript", "typescript-operations"],
            config: {
                dedupeFragments: true,
             }
        },
        "src/": {
            preset: "near-operation-file",
            documents: ['src/**/*.gql'],
            plugins: ["typescript-react-query"],
            config: {
                fetcher: {
                    func: "@gql-fetcher#fetchData", // this is always a fixed path and not a relative path
                    isReactHook: false
                },
                reactQueryVersion: 5,
                dedupeFragments: true,
                importOperationTypesFrom: "Types",
            }
        }
    }