Bug report
We use WebSocketTransport and we need to override the requestBodyCreator parameters.
We define CustomBodyCreator:
struct CustomBodyCreator: RequestBodyCreator {
public func requestBody<Operation: GraphQLOperation>(
for operation: Operation,
sendOperationIdentifiers: Bool
) -> GraphQLMap {
.....
}
}
we put it when we initialize the WebSocketTransport:
WebSocketTransport(request: request, requestBodyCreator: CustomBodyCreator())
The method call in WebSocketTransport don't use the method define in the procotol :
func sendHelper<Operation: GraphQLOperation>(operation: Operation, resultHandler: @escaping (_ result: Result<JSONObject, Error>) -> Void) -> String? {
let body = requestBodyCreator.requestBody(for: operation, sendOperationIdentifiers: self.sendOperationIdentifiers)
....
return sequenceNumber
}
But requestBody from our struct is never call.
There is a an extension for RequestBodyCreator that define the function in the protocol :
extension RequestBodyCreator {
/// Creates a `GraphQLMap` out of the passed-in operation
///
/// - Parameters:
/// - operation: The operation to use
/// - sendOperationIdentifiers: Whether or not to send operation identifiers. Defaults to false.
/// - sendQueryDocument: Whether or not to send the full query document. Defaults to true.
/// - autoPersistQuery: Whether to use auto-persisted query information. Defaults to false.
/// - Returns: The created `GraphQLMap`
public func requestBody<Operation: GraphQLOperation>(for operation: Operation,
sendOperationIdentifiers: Bool = false,
sendQueryDocument: Bool = true,
autoPersistQuery: Bool = false) -> GraphQLMap {
.....
}
Why can put this default implementation in ApolloRequestBodyCreator directly ?
// Helper struct to create requests independently of HTTP operations.
public struct ApolloRequestBodyCreator: RequestBodyCreator {
// Internal init methods cannot be used in public methods
public init() { }
}
Why we can't override this ?
Versions
Please fill in the versions you're currently using:
apollo-ios SDK version: 0.34.1
- Xcode version: 12.0.1
- Swift version: 5.2
Further details
We need to override this to make WebSocketTransportwith AppSyncfrom AWS
Bug report
We use
WebSocketTransportand we need to override therequestBodyCreatorparameters.We define
CustomBodyCreator:we put it when we initialize the
WebSocketTransport:The method call in
WebSocketTransportdon't use the method define in the procotol :But
requestBodyfrom our struct is never call.There is a an extension for
RequestBodyCreatorthat define the function in the protocol :Why can put this default implementation in
ApolloRequestBodyCreatordirectly ?Why we can't override this ?
Versions
Please fill in the versions you're currently using:
apollo-iosSDK version: 0.34.1Further details
We need to override this to make
WebSocketTransportwithAppSyncfrom AWS