@@ -164,27 +164,35 @@ where
164164/// whether to send a 200 or 400 HTTP status code.
165165#[ derive( Clone , Debug , PartialEq ) ]
166166pub struct GraphQLResponse < S = DefaultScalarValue > (
167- pub Result < ( Value < S > , Vec < ExecutionError < S > > ) , GraphQLError > ,
167+ Result < ( Value < S > , Vec < ExecutionError < S > > ) , GraphQLError > ,
168168) ;
169169
170170impl < S > GraphQLResponse < S >
171171where
172172 S : ScalarValue ,
173173{
174- /// Constructs new `GraphQLResponse` using the given result
174+ /// Constructs a new [`GraphQLResponse`] from the provided execution [`Result`].
175+ #[ must_use]
175176 pub fn from_result ( r : Result < ( Value < S > , Vec < ExecutionError < S > > ) , GraphQLError > ) -> Self {
176177 Self ( r)
177178 }
178179
179- /// Constructs an error response outside of the normal execution flow
180+ /// Unwraps this [`GraphQLResponse`] into its underlying execution [`Result`].
181+ pub fn into_result ( self ) -> Result < ( Value < S > , Vec < ExecutionError < S > > ) , GraphQLError > {
182+ self . 0
183+ }
184+
185+ /// Constructs an error [`GraphQLResponse`] outside the normal execution flow.
186+ #[ must_use]
180187 pub fn error ( error : FieldError < S > ) -> Self {
181- GraphQLResponse ( Ok ( ( Value :: null ( ) , vec ! [ ExecutionError :: at_origin( error) ] ) ) )
188+ Self ( Ok ( ( Value :: null ( ) , vec ! [ ExecutionError :: at_origin( error) ] ) ) )
182189 }
183190
184- /// Was the request successful or not?
191+ /// Indicates whether this [`GraphQLResponse`] contains a successful execution [`Result`].
185192 ///
186- /// Note that there still might be errors in the response even though it's
187- /// considered OK. This is by design in GraphQL.
193+ /// **NOTE**: There still might be errors in the response even though it's considered OK.
194+ /// This is by design in GraphQL.
195+ #[ must_use]
188196 pub fn is_ok ( & self ) -> bool {
189197 self . 0 . is_ok ( )
190198 }
0 commit comments