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

Quotes in operation identifers is not escaped #3268

Closed
shkhaliq opened this issue Oct 30, 2023 · 4 comments · Fixed by apollographql/apollo-ios-dev#111
Closed

Quotes in operation identifers is not escaped #3268

shkhaliq opened this issue Oct 30, 2023 · 4 comments · Fixed by apollographql/apollo-ios-dev#111
Assignees
Labels
bug Generally incorrect behavior needs investigation planned-next Slated to be included in the next release

Comments

@shkhaliq
Copy link

Summary

Seems like its a regression and it was previously fixed in #2671.

Using operationIdentifiersPath or operationManifest both don't handle double quotes correctly.

  "bbaca28047784aaadd194fb4ad2b59b63a9f327cd3026f464169bf9271ff7b63" : {
    "name": "SomeLayout",
    "source": "query SomeLayout { viewLayout { __typename someDetails(variant: "create") { __typename confirm { __typename title return description textButton someImage { __typename url } } } } }"
  },

apollo-ios SDK version: 1.6.1
Xcode version: 14.3.1
Swift version: 5.8.1
Package manager: SPM

Version

1.6.1

Steps to reproduce the behavior

  1. Generate code for an operation which contains a string literal value, like "query Sections($id: String!, platform: "ios")"
  2. Add generated code to project
  3. Attempt to build project
  4. Observe compiler error; generated code will contain String with non-escaped quotes like "query Sections($id: String!, platform: "ios")"

Logs

No response

Anything else?

No response

@shkhaliq shkhaliq added bug Generally incorrect behavior needs investigation labels Oct 30, 2023
@AnthonyMDev AnthonyMDev self-assigned this Oct 30, 2023
@AnthonyMDev AnthonyMDev added this to the Patch Releases (1.x.x) milestone Oct 30, 2023
@AnthonyMDev AnthonyMDev added the planned-next Slated to be included in the next release label Oct 30, 2023
@AnthonyMDev
Copy link
Contributor

Thanks for bringing this regression to our attention. I'm working on getting this resolved today!

@AnthonyMDev
Copy link
Contributor

@shkhaliq I think I need a little clarification here. I'm unable to reproduce an error in the actual generated code.

It does seem that we aren't escaping the " properly in the operation manifest JSON file, making the JSON invalid. I'm going to get that fixed ASAP.

But it sounds like you're saying that there is a compilation error in the actual generated operation files. I'm not able to reproduce that. The operation files are using Swift Raw Strings which should not need the special characters to be escaped. In my tests, they are compiling and working just fine.

Can you confirm if you are just reporting the invalid JSON manifest file, or is there some other error you're experiencing in the actual generated Swift operation files?

@shkhaliq
Copy link
Author

Sorry I am not getting a compilation error. I should have corrected myself. I am getting an error when I am trying persist the queries to production. After running apollo-ios-cli generate-operation-manifest. I am trying to parse the JSON file using ruby

require 'JSON'
JSON.parse(File.read(some_file))

This ends up throwing an exception which it didn't before and escaping the "" fixes the issue

@AnthonyMDev
Copy link
Contributor

Got it. Thanks for clarifying. The fix for this is up here! I'll be getting this into the next release 1.7.0, which is coming this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Generally incorrect behavior needs investigation planned-next Slated to be included in the next release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants