Open n10000k opened 3 years ago
Alternative solution This would work a better way instead of executing the extension many times;
projects:
Workspaces:
schemaPath: src/graphql/Workspaces/schema.json
includes:
- src/graphql/Workspaces/**/*.ts
excludes:
- ./amplify/**
extensions:
amplify:
codeGenTarget: typescript
generatedFiles:
- src/utils/API.ts
- amplify/backend/API.ts
docsFilePaths:
- src/graphql/Workspaces
- amplify/backend/Workspaces
maxDepth: 2
extensions:
amplify:
version: 3
An argument made this though could be that you're restricted to one language output at this point. Your frontend is javascript, but your lambda function is python.. it's not going to like the typescript output.
Hi @uncodable Thank you for taking time and requesting this feature. We are working on making the codegen configuration more flexible and customizable. Please look out for an RFC on this.
Meanwhile, if you hadn't figured out already, you could edit the .graphqlconfig.yml
file in your project root, edit the path to generatedFiles
and run amplify codegen
to generate the code at a different place.
Thanks for the update @phani-srikar it's a blocker at the moment on my current project 👍🏻
@uncodable just wanted to let you know that we've publish an RFC to address this and other code generation issues. Would love to have your feedback! https://github.com/aws-amplify/amplify-cli/issues/6898
@uncodable just wanted to let you know that we've publish an RFC to address this and other code generation issues. Would love to have your feedback! aws-amplify/amplify-cli#6898
Any news when it will be ready? Some years already passed.
@hackmajoris as a workaround i found this to be working perfectly fine
(working only if you agree to generate all possible queries and types for some reason when you add/re-add codegen
)
projects:
functionsonsteroids:
schemaPath: amplify/backend/api/functionsonsteroids/build/schema.graphql
includes:
- src/graphql/**/*.graphql
excludes:
- ./amplify/**
extensions:
amplify:
codeGenTarget: angular
generatedFileName: src/app/API.service.ts
docsFilePath: src/graphql
region: eu-central-1
apiId: null
maxDepth: 2
lambdaShared:
schemaPath: amplify/backend/api/functionsonsteroids/build/schema.graphql
includes:
- projects/lambda-shared/src/lib/**/*.ts
excludes:
- ./amplify/**
extensions:
amplify:
codeGenTarget: typescript
generatedFileName: projects/lambda-shared/src/lib/generated/app-sync.models.ts
docsFilePath: projects/lambda-shared/src/lib/generated/
region: eu-central-1
apiId: null
maxDepth: 2
extensions:
amplify:
version: 3
@hackmajoris as a workaround i found this to be working perfectly fine
(working only if you agree to generate all possible queries and types for some reason when you add/re-add
codegen
)projects: functionsonsteroids: schemaPath: amplify/backend/api/functionsonsteroids/build/schema.graphql includes: - src/graphql/**/*.graphql excludes: - ./amplify/** extensions: amplify: codeGenTarget: angular generatedFileName: src/app/API.service.ts docsFilePath: src/graphql region: eu-central-1 apiId: null maxDepth: 2 lambdaShared: schemaPath: amplify/backend/api/functionsonsteroids/build/schema.graphql includes: - projects/lambda-shared/src/lib/**/*.ts excludes: - ./amplify/** extensions: amplify: codeGenTarget: typescript generatedFileName: projects/lambda-shared/src/lib/generated/app-sync.models.ts docsFilePath: projects/lambda-shared/src/lib/generated/ region: eu-central-1 apiId: null maxDepth: 2 extensions: amplify: version: 3
Thank you. I have implemented the exact same approach and can confirm that it works fine. PS: I do use Nx to manage the monorepo, and https://nx.dev/more-concepts/grouping-libraries comes in rescue when dealing with sharing libraries.
What is the easiest way to get codeGenTarget: typescript #and graphql
, to output all other things equal?
Is your feature request related to a problem? Please describe. I want to output typescript types to lambda functions as well as my frontend application also.
Describe the solution you'd like The ability to have many extensions with the same key as
amplify
within the same project:Describe alternatives you've considered Having a folder in the root directory to allow types to be read from there, however it's not easy and requires extra permissions and npm won't let you read outside the main dir it's being ran from. So this will be an issue for lambda functions.