I'm using the following project structure:
.
โโโ package.json
โโโ node_modules
โ โโโ @forte-music/schema
โ โโโ schema.graphql
โโโ src
โโโ __generated__
โโโ query.ts
In package json
"apollo": {
"client": {
"service": {
"name": "forte",
"localSchemaFile": "./node_modules/@forte-music/schema/schema.graphql"
}
}
},
When using
apollo codegen:generate --queries 'src/**/*.{graphql,ts,tsx}' --target typescript
A __generated__ folder is added in the project root.
โโโ globalTypes.ts
Is there a way to specify an output root? I would like the __generated__ folder to be in the src folder and nothing outside src to be affected.
Hey @0xcaff, sorry for the delayed response here. It looks like you may have found a way to achieve what you needed, but we also have the --outputFlat flag which is what I think you wanted. The README at the root of this project enumerates all the possible flags. You can get the same printout by running npx apollo client:codegen --help. Hope this is helpful - feel free to reopen a separate issue if you're still having any problems ๐
No, --outputFlat puts all the output into a single directory. This is not the desired behavior. I want to put the globalTypes.ts under src/__generated__/globalTypes.ts instead of ./__generated__/globalTypes.ts.
I am also having the same issue...trying to generate the globalTypes.ts under the src/__generated__ folder and it does, but it also creates an empty __generated__ folder at my project root (where package.json is located).
This is what my command looks like
sh
apollo client:codegen --target=typescript --globalTypesFile=src/__generated__/globalTypes.ts __generated__
I am also having this issue too.
I added this to the script to resolve the issue. The only thing is that it still creates an empty __generated__ folder at root :|
--globalTypesFile="src/__generated__/globalTypes.d.ts"
@masashiswingle any luck on not automatically creating the generated folder?
I got it working with
apollo client:codegen --target=typescript --outputFlat './src/__generated__'
It's just that you have to make sure that the __generated__ folder exists
Most helpful comment
No,
--outputFlatputs all the output into a single directory. This is not the desired behavior. I want to put theglobalTypes.tsundersrc/__generated__/globalTypes.tsinstead of./__generated__/globalTypes.ts.