Open Romanchuk opened 2 years ago
oh yeah I will import the function from graphql-codegen as my PR was merged:
https://github.com/dotansimha/graphql-code-generator/pull/7017
Looks like I'm hitting this as well:
I'm using the new client
preset and so my config is called codegen.ts
.
@neongreen this is interesting. I will put guard in place for this type error to never happen, but it's weird, because according to graphql-codegen/cli a config object should be always returned
@neongreen in 1.1.0 it won't find find your config anyway, but at least the type error should be fixed. BTW what config do you use? generateSearchPlaces.ts is exact copy of @graphql-codegen/cli so it should be able to find all the config files the same.
@Romanchuk
graphql-codegen-vscode didn't even alert that it can't find config. It just didn't run silently.
In 1.1.0 it should tell you that config was not found, when you explicitly run the command.
@capaj here's my config:
// codegen.ts
import type { CodegenConfig } from '@graphql-codegen/cli'
import { printSchema } from 'graphql'
import { schema } from '@lib/graphql/schema'
const config: CodegenConfig = {
schema: printSchema(schema),
documents: ['{components,lib,pages}/**/!(*.graphql).{ts,tsx}'],
generates: {
'./generated/graphql/': {
preset: 'client',
plugins: [],
},
},
}
export default config
I also have a graphql.config.json
but I'm not sure if that's relevant. Although tbh now I'm not 100% sure which config the extension is looking for — is it the codegen config or the "single" graphql-config config?
Update: after upgrading to 1.1.0 I'm getting a different error, see #29.
I haven't tested with a ts file as config. I always use yaml or json.
Will try next weekend.
@capaj wondered if you managed to look into this? As far as I can tell it's just ignoring my codegen.ts file.
I've struggled when trying to use single graphql config file for all vscode extensions (graphql releated):
graphql.vscode-graphql and @graphql-codegen/cli both searching configs by graphql-config rules
So for example if you have
graphql.config.js
file for config.npm exec -- graphql-codegen
)but
graphql-codegen-vscode
won't, because it doesnt relay on @graphql-codegen/cli config search, it has it's own generateSearchPlaces.tsSo to setup "single" config i dive into graphql-codegen-vscode and found out that it has over config search logic. According to it i created
codegen.js
with content:Not very clean... Also until i created that file graphql-codegen-vscode didn't even alert that it can't find config. It just didn't run silently.
From my perspective as a creators of a 3rd party libraries/extensions based on a some original lib we should not override native/original logic. Because if we do - user of our lib must know docs of original lib and also our docs (if it exists). And our library inevitably will go out of date or you will need keep an eye on each release and sync your code with original.
So
graphql-codegen-vscode
should not override native behavior of @graphql-codegen/cli tooling. In that particular case - should not have alternative config search.