JSONRequest
CLASS
JSONRequest
1open class JSONRequest<Operation: GraphQLOperation>: HTTPRequest<Operation>A request which sends JSON related to a GraphQL operation.
Properties
requestBodyCreator
1public let requestBodyCreator: RequestBodyCreatorautoPersistQueries
1public let autoPersistQueries: BooluseGETForQueries
1public let useGETForQueries: BooluseGETForPersistedQueryRetry
1public let useGETForPersistedQueryRetry: BoolisPersistedQueryRetry
1public var isPersistedQueryRetry = falsebody
1public var body: JSONEncodableDictionaryserializationFormat
1public let serializationFormat = JSONSerializationFormat.selfMethods
init(operation:graphQLEndpoint:contextIdentifier:clientName:clientVersion:additionalHeaders:cachePolicy:autoPersistQueries:useGETForQueries:useGETForPersistedQueryRetry:requestBodyCreator:)
1public init(
2 operation: Operation,
3 graphQLEndpoint: URL,
4 contextIdentifier: UUID? = nil,
5 clientName: String,
6 clientVersion: String,
7 additionalHeaders: [String: String] = [:],
8 cachePolicy: CachePolicy = .default,
9 autoPersistQueries: Bool = false,
10 useGETForQueries: Bool = false,
11 useGETForPersistedQueryRetry: Bool = false,
12 requestBodyCreator: RequestBodyCreator = ApolloRequestBodyCreator()
13)Designated initializer
Parameters:
operation: The GraphQL Operation to execute
graphQLEndpoint: The endpoint to make a GraphQL request to
contextIdentifier: [optional] A unique identifier for this request, to help with deduping cache hits for watchers. Defaults to
nil.clientName: The name of the client to send with the
"apollographql-client-name"headerclientVersion: The version of the client to send with the
"apollographql-client-version"headeradditionalHeaders: Any additional headers you wish to add by default to this request
cachePolicy: The
CachePolicyto use for this request.autoPersistQueries:
trueif Auto-Persisted Queries should be used. Defaults tofalse.useGETForQueries:
trueif Queries should useGETinstead ofPOSTfor HTTP requests. Defaults tofalse.useGETForPersistedQueryRetry:
trueif when an Auto-Persisted query is retried, it should useGETinstead ofPOSTto send the query. Defaults tofalse.requestBodyCreator: An object conforming to the
RequestBodyCreatorprotocol to assist with creating the request body. Defaults to the providedApolloRequestBodyCreatorimplementation.
Parameters
| Name | Description |
|---|---|
| operation | The GraphQL Operation to execute |
| graphQLEndpoint | The endpoint to make a GraphQL request to |
| contextIdentifier | [optional] A unique identifier for this request, to help with deduping cache hits for watchers. Defaults to nil. |
| clientName | The name of the client to send with the "apollographql-client-name" header |
| clientVersion | The version of the client to send with the "apollographql-client-version" header |
| additionalHeaders | Any additional headers you wish to add by default to this request |
| cachePolicy | The CachePolicy to use for this request. |
| autoPersistQueries | true if Auto-Persisted Queries should be used. Defaults to false. |
| useGETForQueries | true if Queries should use GET instead of POST for HTTP requests. Defaults to false. |
| useGETForPersistedQueryRetry | true if when an Auto-Persisted query is retried, it should use GET instead of POST to send the query. Defaults to false. |
| requestBodyCreator | An object conforming to the RequestBodyCreator protocol to assist with creating the request body. Defaults to the provided ApolloRequestBodyCreator implementation. |
toURLRequest()
1open override func toURLRequest() throws -> URLRequest==(_:_:)
1public static func == (lhs: JSONRequest<Operation>, rhs: JSONRequest<Operation>) -> Boolhash(into:)
1public override func hash(into hasher: inout Hasher)