Describe the bug
After initial amplify-cli setup on ios, after running on the terminal amplify add api then amplify push, the default API.swift file in not being generated or created.
I do receive ✔ Generated GraphQL operations successfully and saved at graphql ✔ All resources are updated in the cloud.
but after that I get an error error: uncaughtException: Cannot create property 'addTypename' on string ''
To Reproduce
Steps to reproduce the behavior:
error: uncaughtException: Cannot create property 'addTypename' on string ''Expected behavior
No error and API.swift file is generated according to the setup docs.
@larryranches What version of amplify are you running? You can check this via amplify -v.
Could you also share your directory structure for your project? (want to know where exactly the queries, mutations, subscriptions get stored).
@kaustavghosh06 I'm using the latest currently at 0.1.33
I'm seeing this as well. Basically all default settings.
@kaustavghosh06 even if I remove the api, uninstall amplify cli and reinstall version 0.1.32 and start over I still get it??? But on my machine that already had 0.1.32 it works!?!?!
@kaustavghosh06 I deleted the whole project and started over and still got it. So weird.
@bearc0025 you mean, you still get the error? Could you try using v 0.1.33? We released a new version last friday.
@kaustavghosh06 I was using 0.1.33 and was getting the error. I went back to 0.1.32 and am still getting it. I'm not trying a completely fresh project, etc.
@kaustavghosh06 Sorry, I meant I am NOW trying a completely fresh project. It still didn't work.
I'm recording a course for Lynda.com/Linkedin Learning and prepped it all fine. Now I'm literally in a recording booth and it won't work w/ this new version.
I had the course scripted all out and it worked fine last week. I run the same steps on a new machine and I get this error.
@bearc0025 you might want to do an npm install -g @aws-amplify/[email protected] to revert back to the old version of the CLI since you mentioned it was working previously for you with that version. Until then, will try to root cause the issue with version @0.1.33. It’ll be helpful for us to root cause the issue if you provide us with your annotated graphql schema.
@kaustavghosh06 I'll try that but going back to 0.1.32 didn't work and that's the version that worked as of Saturday on my prep computer.
Can you try using @0.1.31 on a fresh project and share your annotated schema? Also, which OS are you using? And what’s your node version that you’re using?
@kaustavghosh06 I'll have to try that in the morning. I'll send the results and versions then. thanks!
@kaustavghosh06 I tried 0.1.31 and got the same thing.
When I install any of these versions we've discussed, I get this:
npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
/usr/local/bin/amplify -> /usr/local/lib/node_modules/@aws-amplify/cli/bin/amplify
npm WARN [email protected] requires a peer of graphql@^0.11.0 || ^0.12.0 || ^0.13.0 but none is installed. You must install peer dependencies yourself.
Ah I see the issue, we were able to reproduce it. For the time being, until we resolve the issue can you install graphql@^0.11.0 || ^0.12.0 || ^0.13 package in your global node modules for the CLI to access? This should temporarily fix the issue. We’re looking into fixing this ASAP.
@kaustavghosh06 I tried that but got the same thing:
npm install -g [email protected]
I'm doing it w/ the 0.1.33 cli - should I go back to 0.1.32?
I uninstalled it and did this and still got it:
npm install -g graphql@^0.11.0 || ^0.12.0 || ^0.13
I'm sure I'm doing something wrong if you've found a temp fix but I'm not sure what it is. Thanks for the help!
You're not alone, I'm dealing with this same issue. I've also had several codegen issues that I'm trying to work through where the GQL query for iOS doesn't even ask for all the required information in a nested query.
@kaustavghosh06 I've tried a variety of permutations of these but can't get it to codegen w/o that error. If you got it working w/ that route, can you send the specific steps? Thanks!
@MageMasher Sorry to hear that. Hopefully they'll have a fix up soon.
I had this all working on 1.28 but i'm glad to know I'm not crazy and that other folks are running into these issues as well. @kaustavghosh06 can you update us here when there is a determined work around or fix?
@MageMasher we’re actively looking this issue today. We’ll publish to NPM as soon as we have a fix for it.
Hey guys, we just submitted and merged a PR for a fix for this -> https://github.com/aws-amplify/amplify-cli/pull/442
It's in our test/deploy pipeline and I'll update this thread once we have the stable NPM version released today.
@bearc0025 This issue was tied just to iOS projects and you might've tried codegen with some other type of project previously (android or javascript) which might've not thrown any errors.
@kaustavghosh06 is #441 related to this issue?
@MageMasher The fix is related to the issue/error mentioned in the original description - error: uncaughtException: Cannot create property 'addTypename' on string '' which doesn't allow users to successfully create API.swift file as a part of the codegen flow for their iOS projects.
@kaustavghosh06 is #441 related to this issue?
No, its #442
We published a new version of the CLI to NPM just now -> 0.1.34 to fix this issue. Please go ahead and use the latest version and please re-open this issue if you're having the same problems.
Thanks! Will check it out now!
It looks like it worked!
car-booth-06-mac:Thoughts bearcahill$ amplify codegen
✔ Downloaded the schema
✔ Generated GraphQL operations successfully and saved at graphql
✔ Code generated successfully and saved in file API.swift
car-booth-06-mac:Thoughts bearcahill$
Although I did get the same warning:
npm WARN [email protected] requires a peer of graphql@^0.11.0 || ^0.12.0 || ^0.13.0 but none is installed. You must install peer dependencies yourself.
I'll keep you posted if I see anything related but so far, so good. Thanks!
try this
$export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/YOURUSERNAME/.npm-global/bin"
HOPE it might work!! 🙂