File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { print } from 'graphql/language/printer' ;
2
2
import { parse } from 'graphql/language/parser' ;
3
+ import { DocumentNode } from "graphql" ;
3
4
4
5
export default class Logger {
5
6
private readonly enabled : boolean ;
@@ -24,12 +25,17 @@ export default class Logger {
24
25
}
25
26
}
26
27
27
- // TODO also accept gql parsed queries
28
- public logQuery ( query : string ) {
28
+ public logQuery ( query : string | DocumentNode ) {
29
29
if ( this . enabled ) {
30
30
try {
31
31
this . group ( 'Sending query:' )
32
- console . log ( this . prettify ( query ) ) ;
32
+
33
+ if ( typeof query === 'object' && query . loc ) {
34
+ console . log ( this . prettify ( query . loc . source . body ) ) ;
35
+ } else {
36
+ console . log ( this . prettify ( < string > query ) ) ;
37
+ }
38
+
33
39
this . groupEnd ( ) ;
34
40
} catch ( e ) {
35
41
console . error ( '[Vuex-ORM-Apollo] There is a syntax error in the query!' , e , query ) ;
You can’t perform that action at this time.
0 commit comments