-
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: download introspection schema when apiId is passed #684
Conversation
@@ -38,9 +38,9 @@ async function add(context, apiId = null, region = 'us-east-1') { | |||
} | |||
|
|||
const schemaPath = ['schema.graphql', 'schema.json'].map(p => path.join(process.cwd(), p)).find(p => fs.existsSync(p)); | |||
if (withoutInit && !schemaPath) { | |||
if (withoutInit && !(apiId || schemaPath)) { |
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.
In the case that schema.json
is already present when running amplify codegen add
, the schema.json
will be overwritten with no warning.
@@ -123,6 +123,8 @@ async function add(context, apiId = null, region = 'us-east-1') { | |||
} else { | |||
schema = getSDLSchemaLocation(apiDetails.name); | |||
} | |||
} else if (apiDetails) { | |||
schema = await downloadIntrospectionSchemaWithProgress(context, apiDetails.id, 'schema.json', 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.
Using introspection schema because the utility function already exists, but we could change to sdl schema.
856d465
to
aff6b45
Compare
a25bac1
to
f6ce898
Compare
f6ce898
to
6424b01
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 <[email protected]>
Description of changes
When
--apiId
is set, the CLI will attempt to download the introspection schema to./schema.json
. When no--region
is suppliedus-east-1
is used. If the api cannot be found the CLI will prompt the customer to try a different region.An additional change (#689) is needed after this PR. 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.
Each of these commands need to initialize a download when outside an amplify project if
apiId
is set in.graphqconfig.yml
.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.