@@ -95,4 +95,62 @@ type Episode {
95
95
expect ( res . body ) . toHaveProperty ( 'data' ) ;
96
96
expect ( res . body . data ) . toBeInstanceOf ( Array ) ;
97
97
} ) ) ;
98
+
99
+ it ( 'explain' , ( ) =>
100
+ graphql
101
+ . execute ( conn , database , '{ Character { name }}' , { '@explain' : true } )
102
+ . then ( res => {
103
+ expect ( res . status ) . toBe ( 200 ) ;
104
+ expect ( res . body ) . toHaveProperty ( 'data' ) ;
105
+ expect ( res . body . data ) . toEqual ( {
106
+ fields : { '0' : { '1' : 'name' } } ,
107
+ plan :
108
+ 'prefix : <http://api.stardog.com/>\n\nFrom all\nProjection(?0, ?1) [#1]\n`─ MergeJoin(?0) [#1]\n +─ Scan[POSC](?0, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, :Character) [#1]\n `─ Scan[PSOC](?0, :name, ?1) [#1]\n' ,
109
+ sparql :
110
+ 'SELECT *\nFROM <tag:stardog:api:context:all>\n{\n?0 rdf:type :Character .\n?0 :name ?1 .\n}\n' ,
111
+ } ) ;
112
+ } ) ) ;
113
+
114
+ it ( 'explainAsJson' , ( ) =>
115
+ graphql
116
+ . execute ( conn , database , '{ Character { name }}' , {
117
+ '@explain' : true ,
118
+ '@explainAsJson' : true ,
119
+ } )
120
+ . then ( res => {
121
+ expect ( res . status ) . toBe ( 200 ) ;
122
+ expect ( res . body ) . toHaveProperty ( 'data' ) ;
123
+ expect ( res . body . data ) . toEqual ( {
124
+ fields : { '0' : { '1' : 'name' } } ,
125
+ plan : {
126
+ dataset : { from : 'all' } ,
127
+ plan : {
128
+ cardinality : 1 ,
129
+ children : [
130
+ {
131
+ cardinality : 1 ,
132
+ children : [
133
+ {
134
+ cardinality : 1 ,
135
+ children : [ ] ,
136
+ label :
137
+ 'Scan[POSC](?0, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, :Character)' ,
138
+ } ,
139
+ {
140
+ cardinality : 1 ,
141
+ children : [ ] ,
142
+ label : 'Scan[PSOC](?0, :name, ?1)' ,
143
+ } ,
144
+ ] ,
145
+ label : 'MergeJoin(?0)' ,
146
+ } ,
147
+ ] ,
148
+ label : 'Projection(?0, ?1)' ,
149
+ } ,
150
+ prefixes : { '' : 'http://api.stardog.com/' } ,
151
+ } ,
152
+ sparql :
153
+ 'SELECT *\nFROM <tag:stardog:api:context:all>\n{\n?0 rdf:type :Character .\n?0 :name ?1 .\n}\n' ,
154
+ } ) ;
155
+ } ) ) ;
98
156
} ) ;
0 commit comments