Skip to content

Commit

Permalink
explicitly test graphql explain support (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
brianru authored and jmrog committed Apr 9, 2019
1 parent 57d4804 commit f5f4072
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions test/graphql.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,62 @@ type Episode {
expect(res.body).toHaveProperty('data');
expect(res.body.data).toBeInstanceOf(Array);
}));

it('explain', () =>
graphql
.execute(conn, database, '{ Character { name }}', { '@explain': true })
.then(res => {
expect(res.status).toBe(200);
expect(res.body).toHaveProperty('data');
expect(res.body.data).toEqual({
fields: { '0': { '1': 'name' } },
plan:
'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',
sparql:
'SELECT *\nFROM <tag:stardog:api:context:all>\n{\n?0 rdf:type :Character .\n?0 :name ?1 .\n}\n',
});
}));

it('explainAsJson', () =>
graphql
.execute(conn, database, '{ Character { name }}', {
'@explain': true,
'@explainAsJson': true,
})
.then(res => {
expect(res.status).toBe(200);
expect(res.body).toHaveProperty('data');
expect(res.body.data).toEqual({
fields: { '0': { '1': 'name' } },
plan: {
dataset: { from: 'all' },
plan: {
cardinality: 1,
children: [
{
cardinality: 1,
children: [
{
cardinality: 1,
children: [],
label:
'Scan[POSC](?0, <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>, :Character)',
},
{
cardinality: 1,
children: [],
label: 'Scan[PSOC](?0, :name, ?1)',
},
],
label: 'MergeJoin(?0)',
},
],
label: 'Projection(?0, ?1)',
},
prefixes: { '': 'http://api.stardog.com/' },
},
sparql:
'SELECT *\nFROM <tag:stardog:api:context:all>\n{\n?0 rdf:type :Character .\n?0 :name ?1 .\n}\n',
});
}));
});

0 comments on commit f5f4072

Please sign in to comment.