apollographql / apollographql/apollo-tooling

suppressSwiftMultilineStringLiterals breaks operationIdentifiers for persisted queries

Open
#2,556 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3k
Forks
460
PR merge metrics
No merged PRs in 30d

Description

**Intended outcome:**

The operationId calculated by the server based on the `queryDocument` of a given operation matches the operationId output by Apollo, even when the classes are generated without multiline String literals.

**Actual outcome:**

The `operationId` created by Apollo is calculated when the query contains newlines, which are not included in the `queryDocument` provided by the generated classes. As a result, the hashes don't match and all query caching fails.

**How to reproduce the issue:**

* Specify `--suppressSwiftMultilineStringLiterals` to Apollo codegen to get classes without multiline strings for `queryDocument`
* Specify `--operationIdsPath=***` to include SHA-256 hashes of each operation for query caching

**Versions**

2.33.9

Contributor guide

Open the contributing guide

Research direction

Start in the Apollo codegen handling for --suppressSwiftMultilineStringLiterals and --operationIdsPath, then trace how operationIds are hashed from queryDocument. Reproduce the mismatch with the flags from the issue; done means the generated queryDocument and server input produce matching SHA-256 operation IDs for persisted-query caching.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, swift, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.