@@ -24,7 +24,9 @@ extension GraphQLHandler {
2424 guard operationType != . mutation else {
2525 throw HTTPError ( . methodNotAllowed, message: " Mutations using GET are disallowed " )
2626 }
27- let graphQLContextComputationInputs = GraphQLContextComputationInputs < Context , WebSocketInitResult > (
27+ let graphQLContextComputationInputs = GraphQLContextComputationInputs<
28+ Context, WebSocketInitResult
29+ > (
2830 hummingbirdRequest: request,
2931 hummingbirdContext: context,
3032 graphQLRequest: graphQLRequest,
@@ -50,21 +52,31 @@ extension GraphQLHandler {
5052 switch mediaType {
5153 case . applicationJson, . applicationJsonGraphQL:
5254 do {
53- graphQLRequest = try await config. coders. jsonDecoder. decode ( GraphQLRequest . self, from: request, context: context)
55+ graphQLRequest = try await config. coders. jsonDecoder. decode (
56+ GraphQLRequest . self,
57+ from: request,
58+ context: context
59+ )
5460 } catch {
5561 throw HTTPError ( . badRequest, message: error. localizedDescription)
5662 }
5763 case . applicationUrlEncoded:
5864 do {
59- graphQLRequest = try await config. coders. urlEncodedFormDecoder. decode ( GraphQLRequest . self, from: request, context: context)
65+ graphQLRequest = try await config. coders. urlEncodedFormDecoder. decode (
66+ GraphQLRequest . self,
67+ from: request,
68+ context: context
69+ )
6070 } catch {
6171 throw HTTPError ( . badRequest, message: error. localizedDescription)
6272 }
6373 default :
6474 throw HTTPError ( . unsupportedMediaType)
6575 }
6676
67- let graphQLContextComputationInputs = GraphQLContextComputationInputs < Context , WebSocketInitResult > (
77+ let graphQLContextComputationInputs = GraphQLContextComputationInputs<
78+ Context, WebSocketInitResult
79+ > (
6880 hummingbirdRequest: request,
6981 hummingbirdContext: context,
7082 graphQLRequest: graphQLRequest,
@@ -103,13 +115,18 @@ extension GraphQLHandler {
103115 // This indicates a request parsing error
104116 return GraphQLResult ( data: nil , errors: [ error] )
105117 } catch {
106- return GraphQLResult ( data: nil , errors: [ GraphQLError ( message: error. localizedDescription) ] )
118+ return GraphQLResult (
119+ data: nil ,
120+ errors: [ GraphQLError ( message: error. localizedDescription) ]
121+ )
107122 }
108123 return result
109124 }
110125
111126 /// https://github.com/graphql/graphql-over-http/blob/main/spec/GraphQLOverHTTP.md#body
112- private func encodeResponse( result: GraphQLResult , request: Request , context: Context ) throws -> Response {
127+ private func encodeResponse( result: GraphQLResult , request: Request , context: Context ) throws
128+ -> Response
129+ {
113130 let acceptHeader = request. headers [ . accept]
114131
115132 if !config. allowMissingAcceptHeader, acceptHeader == nil {
@@ -121,19 +138,31 @@ extension GraphQLHandler {
121138 // Try to respond with the best matching media type, in order
122139 for mediaType in acceptedTypes {
123140 if MediaType . applicationJsonGraphQL. isType ( mediaType) {
124- return try config. coders. graphQLJSONEncoder. encode ( result, from: request, context: context)
141+ return try config. coders. graphQLJSONEncoder. encode (
142+ result,
143+ from: request,
144+ context: context
145+ )
125146 }
126147 if MediaType . applicationJson. isType ( mediaType) {
127148 return try config. coders. jsonEncoder. encode ( result, from: request, context: context)
128149 }
129150 if MediaType . applicationUrlEncoded. isType ( mediaType) {
130- return try config. coders. urlEncodedFormEncoder. encode ( result, from: request, context: context)
151+ return try config. coders. urlEncodedFormEncoder. encode (
152+ result,
153+ from: request,
154+ context: context
155+ )
131156 }
132157 }
133158
134159 // Use the default if configured to do so
135160 if config. allowMissingAcceptHeader {
136- return try config. coders. graphQLJSONEncoder. encode ( result, from: request, context: context)
161+ return try config. coders. graphQLJSONEncoder. encode (
162+ result,
163+ from: request,
164+ context: context
165+ )
137166 }
138167
139168 // Fail
@@ -143,7 +172,8 @@ extension GraphQLHandler {
143172 private func parseAcceptHeader( _ header: String ? ) -> [ MediaType ] {
144173 guard let header = header else { return [ ] }
145174
146- return header
175+ return
176+ header
147177 . split ( separator: " , " )
148178 . compactMap { segment in
149179 MediaType ( from: segment. trimmingCharacters ( in: . whitespaces) )
0 commit comments