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
After using the useGETForQueries option, the ApolloClient's requests include Content-Type: application/json header that triggers a "POST body sent invalid JSON" 400 error. Querying the URL used by the client without a request body and this header results in a successful 200 response. I think this is a bug, but I may be wrong and this could be expected behavior (noob to iOS dev).
Versions
Please fill in the versions you're currently using:
apollo-ios SDK version: 0.40
Xcode version: 12.3
Swift version: 5.3
Package manager: SPM
Steps to reproduce
Network class:
import Foundation
import Apollo
classNetwork{staticletshared=Network()private(set) lazy varapollo:ApolloClient={letclient=URLSessionClient()letcache=InMemoryNormalizedCache()letstore=ApolloStore(cache: cache)letprovider=LegacyInterceptorProvider(client: client, store: store)leturl=URL(string:"https://XXX")!
lettransport=RequestChainNetworkTransport(
interceptorProvider: provider,
endpointURL: url,
useGETForQueries:true)returnApolloClient(networkTransport: transport, store: store)}()}
Run:
Network.shared.apollo.fetch(query:ArticlesQuery(page: currentPage, offset:10)){ result inswitch result {case.success(let graphQLResult):print("result", result)case.failure(let error):print("error", error.localizedDescription)}}
The text was updated successfully, but these errors were encountered:
euirim
changed the title
GET queries include a non-empty request body
GET queries include a Content-Type: application/json header
Jan 26, 2021
Interesting! I guess this is technically a bug, we just haven't seen any issues with this previously since even though we're sending the header we aren't actually sending the body, and it appears most servers will ignore that if there is no body.
I will fix this the next time I have a little time to poke at bugs (because as I said, this is technically incorrect) but you've already found my suggestion for a workaround :)
Bug report
After using the
useGETForQueries
option, the ApolloClient's requests includeContent-Type: application/json
header that triggers a"POST body sent invalid JSON"
400 error. Querying the URL used by the client without a request body and this header results in a successful 200 response. I think this is a bug, but I may be wrong and this could be expected behavior (noob to iOS dev).Versions
Please fill in the versions you're currently using:
apollo-ios
SDK version: 0.40Steps to reproduce
Network class:
Run:
The text was updated successfully, but these errors were encountered: