@@ -4,9 +4,6 @@ import { ASTNode } from '../language/ast';
44import  {  Source  }  from  '../language/source' ; 
55import  {  SourceLocation  }  from  '../language/location' ; 
66
7- // eslint-disable-next-line import/no-cycle 
8- import  {  GraphQLFormattedError  }  from  './formatError' ; 
9- 
107/** 
118 * Custom extensions 
129 * 
@@ -96,3 +93,40 @@ export class GraphQLError extends Error {
9693 * about the error's position in the source. 
9794 */ 
9895export  function  printError ( error : GraphQLError ) : string ; 
96+ 
97+ /** 
98+  * Given a GraphQLError, format it according to the rules described by the 
99+  * Response Format, Errors section of the GraphQL Specification. 
100+  */ 
101+ export  function  formatError ( error : GraphQLError ) : GraphQLFormattedError ; 
102+ 
103+ /** 
104+  * @see  https://github.com/graphql/graphql-spec/blob/master/spec/Section%207%20--%20Response.md#errors 
105+  */ 
106+ export  interface  GraphQLFormattedError < 
107+   TExtensions  extends  Record < string ,  any >  =  Record < string ,  any > 
108+ >  { 
109+   /** 
110+    * A short, human-readable summary of the problem that **SHOULD NOT** change 
111+    * from occurrence to occurrence of the problem, except for purposes of 
112+    * localization. 
113+    */ 
114+   readonly  message : string ; 
115+   /** 
116+    * If an error can be associated to a particular point in the requested 
117+    * GraphQL document, it should contain a list of locations. 
118+    */ 
119+   readonly  locations ?: ReadonlyArray < SourceLocation > ; 
120+   /** 
121+    * If an error can be associated to a particular field in the GraphQL result, 
122+    * it _must_ contain an entry with the key `path` that details the path of 
123+    * the response field which experienced the error. This allows clients to 
124+    * identify whether a null result is intentional or caused by a runtime error. 
125+    */ 
126+   readonly  path ?: ReadonlyArray < string  |  number > ; 
127+   /** 
128+    * Reserved for implementors to extend the protocol however they see fit, 
129+    * and hence there are no additional restrictions on its contents. 
130+    */ 
131+   readonly  extensions ?: TExtensions ; 
132+ } 
0 commit comments