Apollo-ios: Doesn鈥檛 conform to protocol when build with Apollo pod 0.9.0

Created on 29 Jun 2018  路  9Comments  路  Source: apollographql/apollo-ios

2018-06-29 11 11 58

When I update pod 0.8.0 to 0.9.0, models generated by code-gen needs property resultMap. But the code-gen doesn鈥檛 automatically add resultMap, even build fails.
To resolve this problem, I tried to add resultMap one by one to every module in API.swift. However it requires advanced initializers which considers resultMap and established properties like rawValue.
If 0.9.0 needs extra handling, please leave comments.

Most helpful comment

Since apollo-codegen is now part of the new apollo-cli, the build script used to generate API.swift needs to be updated. See the docs for the updated script.

All 9 comments

What version of apollo-codegen are you running? If you use the recommended build script, it should install the right version for the version of the Apollo framework installed in your project automatically.

@martijnwalraven the script was renamed from check-and-run-apollo-cli.sh to check-and-run-apollo-codegen.sh. Thats not documented anywhere.

Leaves the script error:

exec apollo-codegen codegen:generate '--queries=./API/graphql/GetAppointments.graphql
./API/graphql/UpdateAppointment.graphql
./API/graphql/UpdateUserPassword.graphql
./API/graphql/DeleteAppointment.graphql
./API/graphql/CreateAppointment.graphql
./API/graphql/GetCustomers.graphql
./API/graphql/DeleteCustomer.graphql
./API/graphql/CreateCustomer.graphql
./API/graphql/UpdateCustomer.graphql
./API/graphql/Viewer.graphql
./API/graphql/UpdateViewerPassword.graphql
./API/graphql/PasswordReset.graphql' --schema=schema.json API.swift
error: Unknown arguments: queries, schema, codegen:generate, API.swift

apollo-codegen is 0.20.2

Editing the script check-and-run-apollo-codegen.sh Line 73 from exec apollo-codegen "$@" to exec apollo "$@" does the trick.

As @dockay said there's a bit of conflict with the naming check-and-run-apollo-cli.sh to check-and-run-apollo-codegen.sh, should't this be a priority since it's going to lead a lot of people astray?
Also @dockay changing the xec apollo-codegen "$@" to exec apollo "$@" doesn't do the trick for me.

Since apollo-codegen is now part of the new apollo-cli, the build script used to generate API.swift needs to be updated. See the docs for the updated script.

@martijnwalraven Managed to figure it out, thank you!

actually we fixed it with the new build script @martijnwalraven mentioned, but we also did this:
sudo chown -R $(whoami) /usr/local/lib/node_modules/ in terminal, in this way the script can install itself what it needs, this also removes some "newer/older version conflict" errors.

Going to close this one out - current build steps can be found here.

Was this page helpful?
0 / 5 - 0 ratings