You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.
The query hash that is generated by apollo-android does not match the query hash that is generated by apollo-link-persisted-queries.
Investigation
I took a query and the query hash generated by apollo-android and found that query hash was different from the query hash that apollo-link-persisted-queries generates for the same query.
I wrote a command-line utility that performed the same steps as apollo-link-persisted-queries:
a. Read a query string.
b. Perform a graphqlparse on the output of a.
c. Perform a graphqlprint on the output of b.
d. Compute the SHA256 hash on the output of c.
I found that my hash matched the one that apollo-link-persisted-queries generates.
Problem Description
The query hash that is generated by
apollo-android
does not match the query hash that is generated byapollo-link-persisted-queries
.Investigation
I took a query and the query hash generated by
apollo-android
and found that query hash was different from the query hash thatapollo-link-persisted-queries
generates for the same query.I wrote a command-line utility that performed the same steps as
apollo-link-persisted-queries
:a. Read a query string.
b. Perform a
graphql
parse
on the output of a.c. Perform a
graphql
print
on the output of b.d. Compute the SHA256 hash on the output of c.
I found that my hash matched the one that
apollo-link-persisted-queries
generates.I looked at the code and saw that https://github.com/apollographql/apollo-android/blob/master/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/OperationTypeSpecBuilder.kt#L58 filters out newlines while https://github.com/apollographql/apollo-link-persisted-queries/blob/master/src/index.ts#L28-L31 does not.
I added newline stripping to my utility in 2.
I found that my hash now matched the one generated by
apollo-android
.Proposed Solutions
There are two possible, mutually-exclusive solutions:
Either make the change inside
apollo-android
Change https://github.com/apollographql/apollo-android/blob/master/apollo-compiler/src/main/kotlin/com/apollographql/apollo/compiler/OperationTypeSpecBuilder.kt#L58 to be:
.initializer("\$S", operation.sourceWithFragments?.sha256())
Or make the change inside
apollo-link-persisted-queries
Change https://github.com/apollographql/apollo-link-persisted-queries/blob/master/src/index.ts#L30 to be:
Related PR
I raised the same issue in
apollo-android
here: apollographql/apollo-kotlin#1283 .The text was updated successfully, but these errors were encountered: