Skip to content
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

Type does not conform to protocol 'GraphQLOperation' #769

Closed
adamirowe opened this issue Sep 17, 2019 · 12 comments
Closed

Type does not conform to protocol 'GraphQLOperation' #769

adamirowe opened this issue Sep 17, 2019 · 12 comments
Labels
build-issue Issues occurring when attempting to build

Comments

@adamirowe
Copy link

I just upgraded our version of Apollo to 0.15.3 and nearly every query we use has a compile error of

Type 'xxx' does not conform to protocol 'GraphQLOperation'

If I add the Protocol stubs that xCode is suggesting (public var operationName: String), the errors go away. But since this is a dynamically generated file that's obviously not going to work next time I build.

Am I understanding correctly that we'll need to add operationName properties to all of our queries and mutations moving forward? I couldn't find anything in the examples or release notes about this.

@designatednerd
Copy link
Contributor

You should have some updated codegen that will run when this is built, and which will automatically generate operation names. If it does not, try cleaning your build folder and running it again.

@adamirowe
Copy link
Author

You should have some updated codegen that will run when this is built, and which will automatically generate operation names. If it does not, try cleaning your build folder and running it again.

So after updating npm to the latest version, I got past those errors. Now I'm just getting an undefined error, the dreaded:

Command PhaseScriptExecution failed with a nonzero exit code

I have a bunch of lint warnings about nesting too deep, but none that are serious.

@adamirowe
Copy link
Author

It looks like I need to go through and update a bunch of GraphQL -> Result types that weren't showing up in the build error logs. Will let you know if that fixes anything.

@designatednerd
Copy link
Contributor

Yes - I would recommend reading through the changelog for breaking changes you want to be aware of - that's definitely one of them.

I would also recommend clicking on that error in Xcode if it's still showing up, the Apollo CLI will probably have more to say about what went wrong in the details

@designatednerd designatednerd added the build-issue Issues occurring when attempting to build label Sep 18, 2019
@adamirowe
Copy link
Author

So after a bunch of cleaning and rebuilding, closing and opening xcode, and making sure all updates were made as per the changelog, I finally got the project to build with 0.15.3. Unfortunately, we're now seeing the schema being unable to be built on CircleCI.

While I investigate why, it came to me that I have now updated the apollo cli to the latest version and when I switch back to another branch that is running an older Apollo pod version, there will be version inconsistency between the Apollo pod and the CLI. How do people reconcile this issue? Do I need to downgrade my Apollo version when I switch back to a branch that has a different version of the pod?

Do I need to do anything on CircleCI in order to have the right version of the CLI installed in each container?

@designatednerd
Copy link
Contributor

...yeah...this is why #766 is a thing, to be honest.

Generally the check-and-run-cli script should check that you have the proper version installed and use a local version and IN THEORY should also work on CI, but sometimes it doesn't.

We're moving to including the binaries with the pod very shortly to avoid all this nonsense.

@adamirowe
Copy link
Author

Ok, so yeah that is a big change but a welcome one for us, I'm assuming. Since we've never updated the pod version while I've been a part of the project I'm unsure of how changes to the required CLI version may have affected compiling on CircleCI. Based on your last comment on #766, it looks like you are planning to merge that sometime today? Would that increase the version of the pod to install sometime soon or is there a lot more testing to be done post-merge?

Is there a handy chart of what CLI is required for what pod version? Our project had been built on 0.10.1 prior to me upgrading to 0.15.3.

@designatednerd
Copy link
Contributor

yeah there will be a new version when that gets merged.

There isn't a chart, but if you look in check-and-run-apollo-cli.sh for whatever version you have checked out, it should indicate which major.minor version is appropriate

@adamirowe
Copy link
Author

So in order to fix the build issues on CircleCI, we had to change the BuildPhase script for Fetch GraphQL Schema from
apollo schema:download --endpoint="$GRAPHQL_URL" "${SRCROOT}/${TARGET_NAME}/API/schema.json

to

${PODS_ROOT}/Apollo/scripts/check-and-run-apollo-cli.sh schema:download --endpoint="$GRAPHQL_URL" "${SRCROOT}/${TARGET_NAME}/API/schema.json"

If anyone runs in to a similar issue. Looks like the Docker image that CircleCI spun up was unable to find the script by just running the apollo command. Not sure if this is an Environment Variable that needs to be added or something that should've been generated in node_modules with the installation of the new apollo version, but it did not in our setup.

@designatednerd
Copy link
Contributor

OK cool - thank you for the heads up on that, I'll update the docs there.

Anything else or can we close this issue out?

@adamirowe
Copy link
Author

adamirowe commented Sep 19, 2019

All set for now. Thank you very much for your responsiveness and help here, @designatednerd!

@designatednerd
Copy link
Contributor

@adamirowe please see #776 for updated docs, lmk if you have feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-issue Issues occurring when attempting to build
Projects
None yet
Development

No branches or pull requests

2 participants