ApolloClient.builder()
.serverUrl(Endpoints.GRAPHQL_BASE_URL)
.httpCache(new ApolloHttpCache(cacheStore))
.defaultHttpCachePolicy(HttpCachePolicy.NETWORK_ONLY)
.addCustomTypeAdapter(CustomType.DATE, getCustomDateAdapter())
.addCustomTypeAdapter(CustomType.CURSOR, getCustomCursorAdapter())
.enableAutoPersistedQueries(false)
.okHttpClient(client)
.build();
Even after disabling persistedqueries() option it still produces the same error and I haven't been able to make any request.
Have the same problem
Request log:
D/OkHttp: --> POST https://api.groundzero.ml/graphql h2
D/OkHttp: Content-Type: application/json; charset=utf-8
D/OkHttp: Content-Length: 636
D/OkHttp: Accept: application/json
D/OkHttp: X-APOLLO-OPERATION-ID: ad8c5bcbbb1a27e99d3a4fbb04dda14c974385200c6bee29e9bde1b94233c298
D/OkHttp: X-APOLLO-OPERATION-NAME: ProjectsQuery
D/OkHttp: X-APOLLO-CACHE-KEY: 74b1d8773a646d1af68b693ef46c11df
D/OkHttp: X-APOLLO-CACHE-FETCH-STRATEGY: CACHE_FIRST
D/OkHttp: X-APOLLO-EXPIRE-TIMEOUT: 0
D/OkHttp: X-APOLLO-EXPIRE-AFTER-READ: false
D/OkHttp: X-APOLLO-PREFETCH: false
D/OkHttp: X-APOLLO-CACHE-DO-NOT-STORE: false
D/OkHttp: Host: api.groundzero.ml
D/OkHttp: Connection: Keep-Alive
D/OkHttp: Accept-Encoding: gzip
D/OkHttp: Authorization: keycloak-token
D/OkHttp: Cache-Control: public, max-age=86400
D/OkHttp: User-Agent: Mozilla/5.0 (Android 22; App 1.0.9.1; omega_pro)
D/OkHttp: {"operationName":"ProjectsQuery","variables":{"domains":["groundzero.ml"],"limit":1000,"offset":0},"extensions":{"persistedQuery":{"version":1,"sha256Hash":"ad8c5bcbbb1a27e99d3a4fbb04dda14c974385200c6bee29e9bde1b94233c298"}},"query":"query ProjectsQuery($domains: [String!], $limit: Int, $offset: Int) { sections(domains: $domains) { __typename projects { __typename projects(limit: $limit, offset: $offset) { __typename url projectId title status banner { __typename url } volumes { __typename count } } } }}"}
OkHttp: --> END POST (636-byte body)
Response:
W/System.err: com.apollographql.apollo.exception.ApolloHttpException: HTTP 400
W/System.err: at com.apollographql.apollo.internal.interceptor.ApolloParseInterceptor.parse(ApolloParseInterceptor.java:105)
W/System.err: at com.apollographql.apollo.internal.interceptor.ApolloParseInterceptor$1.onResponse(ApolloParseInterceptor.java:53)
W/System.err: at com.apollographql.apollo.internal.interceptor.ApolloServerInterceptor$1$1.onResponse(ApolloServerInterceptor.java:94)
W/System.err: at okhttp3.RealCall$AsyncCall.execute(RealCall.java:206)
W/System.err: at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
W/System.err: at java.lang.Thread.run(Thread.java:818)
Log from Tomcat:
tomcat_1 | 10:31:59.804 [http-nio2-8080-exec-13] WARN graphql.execution.SimpleDataFetcherExceptionHandler - Exception while fetching data (/sectionByDomain) : null
tomcat_1 | java.lang.NullPointerException: null
tomcat_1 | at ru.ruranobe.api.service.graphql.resolvers.Query.sectionByDomain(Query.java:57) ~[classes/:?]
tomcat_1 | at ru.ruranobe.api.service.graphql.resolvers.QueryMethodAccess.invoke(Unknown Source) ~[reflectasm-1.11.3.jar:?]
Client:
apolloClient = ApolloClient.builder()
.enableAutoPersistedQueries(false)
.serverUrl("https://api.groundzero.ml/graphql")
.okHttpClient(okHttpClient)
.httpCache(new ApolloHttpCache(new DiskLruHttpCacheStore(
new File(context.getCacheDir(), "responses-cache"),
50 * 1024 * 1024)))
.addCustomTypeAdapter(CustomType.LOCALDATETIME, new CustomDateAdapter())
.build();
+1 with 1.0.1-SNAPSHOT
Real issue: https://github.com/apollographql/apollo-android/issues/1155
There's a way to fix this, but it should be fixed on the generator side.
If you:
use this version:
buildscript {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
dependencies {
classpath "com.apollographql.apollo:apollo-gradle-plugin:1.0.1-SNAPSHOT"
}
}
repositories {
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
}
dependencies {
implementation 'com.apollographql.apollo:apollo-runtime:1.0.1-20181206.012104-45'
...
}
(you probably also want to use a specific plugin version)
If you:
- need to use the most recent version (e.g. due to Gradle 5.0 support)
- have issues with SHA generation
- don't need auto persisted queries
use this version:
dependencies { implementation 'com.apollographql.apollo:apollo-runtime:1.0.1-20181206.012104-45' ... }
Didn't work for me (can't resolve this dependency), btw where did you find this version?
Didn't work for me (can't resolve this dependency), btw where did you find this version?
@7Koston oh, sorry - I forgot to mention that this version is available only in snapshot repository. I have updated my comment, please, take a look.
Usually, one can just depend on X.Y.Z-SNAPSHOT version, but there is no way to know which build is actually gonna be included in a project. I chose a specific build version right before the one that included commit with auto-persisted queries.
EDIT:
Take a look here if you want to check it by yourself: https://oss.sonatype.org/content/repositories/snapshots/com/apollographql/apollo/apollo-runtime/1.0.1-SNAPSHOT/
Thanks now I see. The reason why I could not build the project because of that repository stores only the last 3 builds. Version 1.0.1-20181206.012104-45 is no longer exist, but 1.0.1-20181207.155824-46 works fine. How long? Let's see :)
@vthakur1993 would you mind opening up this issue again?
v1.0.0-alpha4 still doesn't work properly for us, we keep getting provided sha does not match query error.
@scana could you elaborate more on the error? As right now the SHA for provided generated code in com.apollographql.apollo.api.Operation#queryDocument should provide the same as com.apollographql.apollo.api.Operation#operationId
@sav007 forgive me, I don't have much experience with GraphQL.
I've recently joined a project and wanted to migrate it to use Gradle 5.0, which forced me to use the most recent version of apollo-android. Unfortunately, using any build with autoPersistedQueries results in my backend responding with: provided sha does not match query error. Could it mean that there is an issue on our backend side?
Also, would you mind telling me whether calling .enableAutoPersistedQueries(false) should still result in adding this part to a request?
{
"operationName": "MyOperationQuery",
"variables": {},
//THIS PART
"extensions": {
"persistedQuery": {
"version": 1,
"sha256Hash": "72f1c63525ef8af34ee690b2676c96e160a92ca92543337532083ea2662e4090"
}
},
///END
"query": "query MyOperationQuery { something { __typename edges { __typename node { __typename ...Something } } }}fragment Something on Something { __typename databaseId content author { __typename nick avatar { __typename thumbnailUrl } } attachments { __typename url } subject { __typename name }}"
}
because we don't really need this feature for now and I think that this part shouldn't be there if autoPersistedQueries feature is disabled.
@sav007 thanks!
Any chance of releasing this as 1.0.0-alpha5?
I still see this happening in 1.0.0. Should it be sending {"extensions" } block in the body even if we explicitly set the .enableAutoPersistedQueries(false)? All calls are returning a 400.
@vthakur1993 Did the fix work for you or did you find any other work around?
@vthakur1993 Did the fix work for you or did you find any other work around?
https://github.com/apollographql/apollo-android/issues/1161#issuecomment-449564709
@vikrama well the above reply from @looploooop will solve your problem
@vthakur1993 Did the fix work for you or did you find any other work around?
#1161 (comment)
@vikrama well the above reply from @looploooop will solve your problem
No luck with the latest 1.0.1 SNAPSHOT either. I still see it added to the outgoing request.
"extensions":{"persistedQuery":{"version":1,"sha256Hash":"..."}}
But I see that it's not our server that throws a 404, but it's our DNS provider Cloudflare. If I remove that json object, Cloudflare lets it through. Super weird!
https://www.apollographql.com/docs/apollo-server/features/apq#cdn
Have created a new issue #1322
Most helpful comment
@vthakur1993 would you mind opening up this issue again?
v1.0.0-alpha4still doesn't work properly for us, we keep gettingprovided sha does not match queryerror.