-
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: codegen --apiId broken state #689
Conversation
71bba57
to
d40c094
Compare
} else if (project.amplifyExtension.apiId && project.amplifyExtension.region) { | ||
const { | ||
amplifyExtension: { apiId, region }, | ||
} = project; | ||
apis = [await getAppSyncAPIInfo(context, apiId, region)]; |
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.
You could probably refactor this check, destructuring statement, and retrieval into a single utility where given a project
you return an optional api
or something like that, since it's nearly identical to the code in statements.ts
} else if (projects[0].amplifyExtension.apiId && projects[0].amplifyExtension.region) { | ||
const { | ||
amplifyExtension: { apiId, region }, | ||
} = projects[0]; | ||
apis = [await getAppSyncAPIInfo(context, apiId, region)]; |
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.
See prior comment on this shared code.
|
||
for (const cfg of projects) { | ||
const includeFiles = path.join(projectPath, cfg.includes[0]); | ||
const opsGenDirectory = cfg.amplifyExtension.docsFilePath | ||
? path.join(projectPath, cfg.amplifyExtension.docsFilePath) | ||
: path.dirname(path.dirname(includeFiles)); | ||
const schemaPath = path.join(projectPath, cfg.schema); | ||
let region; | ||
let frontend; |
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 reassigned at all, or can this be converted into a ternary const
assignment?
const frontend = withoutInit ? cfg.amplifyExtension.frontend : getFrontEndHandler(context);
} else if (projects[0].amplifyExtension.apiId && projects[0].amplifyExtension.region) { | ||
const { | ||
amplifyExtension: { apiId, region }, | ||
} = projects[0]; | ||
apis = [await getAppSyncAPIInfo(context, apiId, region)]; |
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.
Similar utility here I think.
@@ -4,9 +4,15 @@ const generateIntrospectionSchema = require('./generateIntrospectionSchema'); | |||
const downloadIntrospectionSchemaWithProgress = require('./generateIntrospectionSchemaWithProgress'); | |||
|
|||
async function ensureIntrospectionSchema(context, schemaPath, apiConfig, region, forceDownloadSchema) { | |||
const meta = context.amplify.getProjectMeta(); | |||
let meta; | |||
let withoutInit = 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.
This seems to be unused, unless I'm missing something.
f6ce898
to
6424b01
Compare
f2dc0a8
to
5325040
Compare
…set up locally. (#702) * feat: codegen add --region (#683) * fix: download introspection schema when apiId is passed (#684) * fix: codegen --apiId broken state (#689) * chore: get existing e2e tests passing (#704) * feat: add e2e tests for codegen add when in a non-amplify project (#705) * feat: add e2e tests for codegen add when in a non-amplify project * chore: add some additional test cases * noinit codegen from graphqlconfig (#706) * fix: add missing awaits * chore: fail typegen if no queries are found --------- Co-authored-by: Dane Pilcher <dppilche@amazon.com>
Description of changes
The customer can end in a broken state if:
amplify codegen add --apiId <api-id>
rm -rf schema.json
amplify codegen
There is no way the customer can use the codegen CLI to download the introspection schema.
amplify codegen
,amplify codegen types
, andamplify codegen statements
now download the introspection schema ifapiId
is set in.graphqlconfig.yml
and the project is without amplify init.Issue #, if available
N/A
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.