Using AWS resources in my web app, such as a Cognito user pool and an AppSync GraphQL API, requires careful maintenance in a separate project. When modifications are needed, I rely on the amplify
command to delete and re-import these resources:
$ amplify remove auth
...
$ amplify remove api
...
$ amplify import auth
...
$ amplify codegen add --apiId <my API ID>
...
As far as my experience goes, this method of importing externally managed resources has been effective for the past few months, with minimal issues. If there are better practices out there, I'm open to suggestions from the community.
However, after the most recent delete and re-import process, running the app encountered a compiler error within the TypeScript code generated by amplify codegen
:
$ yarn start
Compiled successfully!
...
webpack compiled successfully
Files successfully emitted, waiting for typecheck results...
Issues checking in progress...
ERROR in src/graphql/queries.ts:21:30
TS2694: Namespace '"<path to project>/src/API"' has no exported member 'SomeAPIOperationQueryVariables'.
19 | }
20 | }
> 21 | ` as GeneratedQuery<APITypes.SomeAPIOperationQueryVariables, APITypes.SomeAPIOperationQuery>;
| ^^^^^^^^^^^^^^^^^^^^^
22 | export const anotherAPIOperation = /* GraphQL */ `query AnotherAPIOperation {
23 | anotherAPIOperation {
24 | color
...
The AppSync API and its schema (alongside the Cognito resources) have functioned well across multiple individual projects over the last couple of months, ruling out any immediate issues in those areas.
The compiler error specifically affects GraphQL operations that do not require arguments - resulting in issues for certain types while other queries and mutations compile without errors.
I've attempted the suggested importing steps and even started fresh by removing all local files associated with amplify
and performing a clean initialization, yet the error persists. What could be causing this issue? Any insights or guidance on troubleshooting would be greatly appreciated.