-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: swift file names #713
Conversation
if (outputs.length === 1) { | ||
const [[, contents]] = outputs; | ||
fs.outputFileSync(path.resolve(outputPath), contents); | ||
if (target === 'swift' && fs.existsSync(outputPath) && fs.statSync(outputPath).isDirectory()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the previous behavior for setting multiple files. https://github.com/aws-amplify/amplify-codegen/blob/9f11cfe396bacc603df84233a1b75feabcadaae6/packages/graphql-types-generator/src/generate.ts#L47C35-L47C102
queries, | ||
target, | ||
introspection, | ||
multipleSwiftFiles: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this flag still needed for the current PR? Looks like the change of consuming this value is not included
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary to ensure that multiple Swift files are not used in the graphql-generator package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently defaulted to true.
const { schema, target, queries, multipleSwiftFiles = true, introspection = false } = options; |
generate(queryFilePaths, schemaPath, outputPath, '', target, '', { | ||
addTypename: true, | ||
complexObjectSupport: 'auto', | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't the new generateTypesHelper
handle multiple swift file generation yet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is bugged. The generateTypesHelper
does not set the correct filenames for the generated types. It will require a more complex fix. This solution will fix current production.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified locally by amplify-dev codegen
. The multiple files are generated when the generatedFileName
is configured as a folder name which already exists. Otherwise it generates single file.
TODO for later PR: a e2e test to cover the single/multiple file generation for swift
Description of changes
Type generation for Swift is always generating multiple files. Additionally the when generating multiple files the filename generated is incorrect.
Fallback to old type generation if generating to multiple files. When using the GraphQL generator directly the filenames will still be incorrect.
Issue #, if available
#711
Description of how you validated changes
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.