Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

Commit

Permalink
Remove functionality to infer addition of neo4j_ignore directive
Browse files Browse the repository at this point in the history
See #189
  • Loading branch information
johnymontana committed Feb 8, 2019
1 parent f1a31a4 commit 4d3ef38
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 27 deletions.
16 changes: 10 additions & 6 deletions src/augment.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,16 @@ const augmentType = (astNode, typeMap, resolvers, rootTypes, config) => {
queryType
);
}
astNode.fields = possiblyAddIgnoreDirective(
astNode,
typeMap,
resolvers,
config
);
// FIXME: inferring where to add @neo4j_ignore directive improperly causes
// fields to be ignored when logger is added, so remove functionality
// until we refactor how to infer when @neo4j_ignore directive is needed
// see https://github.com/neo4j-graphql/neo4j-graphql-js/issues/189
// astNode.fields = possiblyAddIgnoreDirective(
// astNode,
// typeMap,
// resolvers,
// config
// );
return astNode;
};

Expand Down
48 changes: 27 additions & 21 deletions test/cypherTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3762,23 +3762,25 @@ test('Query node with ignored field', t => {
]);
});

test('Query nested node with ignored field (inferred from resolver)', t => {
const graphQLQuery = `query {
Movie {
customField
filmedIn {
name
customField
}
}
}`,
expectedCypherQuery = `MATCH (\`movie\`:\`Movie\` ) RETURN \`movie\` {filmedIn: head([(\`movie\`)-[:\`FILMED_IN\`]->(\`movie_filmedIn\`:\`State\`) | movie_filmedIn { .name }]) } AS \`movie\` SKIP $offset`;

t.plan(1);
return Promise.all([
augmentedSchemaCypherTestRunner(t, graphQLQuery, {}, expectedCypherQuery)
]);
});
// FIXME: ignore this test until inferred addition of @neo4j_ignore directive
// is re-evaluated
// test('Query nested node with ignored field (inferred from resolver)', t => {
// const graphQLQuery = `query {
// Movie {
// customField
// filmedIn {
// name
// customField
// }
// }
// }`,
// expectedCypherQuery = `MATCH (\`movie\`:\`Movie\` ) RETURN \`movie\` {filmedIn: head([(\`movie\`)-[:\`FILMED_IN\`]->(\`movie_filmedIn\`:\`State\`) | movie_filmedIn { .name }]) } AS \`movie\` SKIP $offset`;

// t.plan(1);
// return Promise.all([
// augmentedSchemaCypherTestRunner(t, graphQLQuery, {}, expectedCypherQuery)
// ]);
// });

test('Deeply nested orderBy', t => {
const graphQLQuery = `query {
Expand All @@ -3792,7 +3794,8 @@ test('Deeply nested orderBy', t => {
}
}
}`,
expectedCypherQuery = "MATCH (`movie`:`Movie` ) RETURN `movie` { .title ,actors: apoc.coll.sortMulti([(`movie`)<-[:`ACTED_IN`]-(`movie_actors`:`Actor`) | movie_actors { .name ,movies: apoc.coll.sortMulti([(`movie_actors`)-[:`ACTED_IN`]->(`movie_actors_movies`:`Movie`) | movie_actors_movies { .title }], ['^title','title']) }], ['name']) } AS `movie` ORDER BY movie.title DESC SKIP $offset";
expectedCypherQuery =
"MATCH (`movie`:`Movie` ) RETURN `movie` { .title ,actors: apoc.coll.sortMulti([(`movie`)<-[:`ACTED_IN`]-(`movie_actors`:`Actor`) | movie_actors { .name ,movies: apoc.coll.sortMulti([(`movie_actors`)-[:`ACTED_IN`]->(`movie_actors_movies`:`Movie`) | movie_actors_movies { .title }], ['^title','title']) }], ['name']) } AS `movie` ORDER BY movie.title DESC SKIP $offset";

t.plan(1);
return Promise.all([
Expand All @@ -3807,7 +3810,8 @@ test('Query using enum orderBy', t => {
genre
}
}`,
expectedCypherQuery = "MATCH (`book`:`Book` ) RETURN `book` {_id: ID(`book`), .genre } AS `book` ORDER BY book.genre ASC SKIP $offset";
expectedCypherQuery =
'MATCH (`book`:`Book` ) RETURN `book` {_id: ID(`book`), .genre } AS `book` ORDER BY book.genre ASC SKIP $offset';

t.plan(1);
return Promise.all([
Expand All @@ -3825,7 +3829,8 @@ test('Query using temporal orderBy', t => {
}
}
}`,
expectedCypherQuery = "MATCH (\`temporalNode\`:\`TemporalNode\` ) RETURN \`temporalNode\` {datetime: { formatted: toString(\`temporalNode\`.datetime) }} AS \`temporalNode\` ORDER BY temporalNode.datetime DESC , temporalNode.datetime ASC SKIP $offset";
expectedCypherQuery =
'MATCH (`temporalNode`:`TemporalNode` ) RETURN `temporalNode` {datetime: { formatted: toString(`temporalNode`.datetime) }} AS `temporalNode` ORDER BY temporalNode.datetime DESC , temporalNode.datetime ASC SKIP $offset';

t.plan(1);
return Promise.all([
Expand Down Expand Up @@ -3881,7 +3886,8 @@ test('Deeply nested query using temporal orderBy', t => {
}
}
}`,
expectedCypherQuery = "MATCH (`temporalNode`:`TemporalNode` ) RETURN `temporalNode` {_id: ID(`temporalNode`),datetime: { year: `temporalNode`.datetime.year , month: `temporalNode`.datetime.month , day: `temporalNode`.datetime.day , hour: `temporalNode`.datetime.hour , minute: `temporalNode`.datetime.minute , second: `temporalNode`.datetime.second , millisecond: `temporalNode`.datetime.millisecond , microsecond: `temporalNode`.datetime.microsecond , nanosecond: `temporalNode`.datetime.nanosecond , timezone: `temporalNode`.datetime.timezone , formatted: toString(`temporalNode`.datetime) },temporalNodes: [sortedElement IN apoc.coll.sortMulti([(`temporalNode`)-[:`TEMPORAL`]->(`temporalNode_temporalNodes`:`TemporalNode`) | temporalNode_temporalNodes {_id: ID(`temporalNode_temporalNodes`),datetime: `temporalNode_temporalNodes`.datetime,time: `temporalNode_temporalNodes`.time,temporalNodes: [sortedElement IN apoc.coll.sortMulti([(`temporalNode_temporalNodes`)-[:`TEMPORAL`]->(`temporalNode_temporalNodes_temporalNodes`:`TemporalNode`) | temporalNode_temporalNodes_temporalNodes {_id: ID(`temporalNode_temporalNodes_temporalNodes`),datetime: `temporalNode_temporalNodes_temporalNodes`.datetime,time: `temporalNode_temporalNodes_temporalNodes`.time}], ['datetime','time']) | sortedElement { .*, datetime: {year: sortedElement.datetime.year,formatted: toString(sortedElement.datetime)},time: {hour: sortedElement.time.hour}}][1..3] }], ['^datetime']) | sortedElement { .*, datetime: {year: sortedElement.datetime.year,month: sortedElement.datetime.month,day: sortedElement.datetime.day,hour: sortedElement.datetime.hour,minute: sortedElement.datetime.minute,second: sortedElement.datetime.second,millisecond: sortedElement.datetime.millisecond,microsecond: sortedElement.datetime.microsecond,nanosecond: sortedElement.datetime.nanosecond,timezone: sortedElement.datetime.timezone,formatted: toString(sortedElement.datetime)},time: {hour: sortedElement.time.hour}}] } AS `temporalNode` ORDER BY temporalNode.datetime DESC SKIP $offset";
expectedCypherQuery =
"MATCH (`temporalNode`:`TemporalNode` ) RETURN `temporalNode` {_id: ID(`temporalNode`),datetime: { year: `temporalNode`.datetime.year , month: `temporalNode`.datetime.month , day: `temporalNode`.datetime.day , hour: `temporalNode`.datetime.hour , minute: `temporalNode`.datetime.minute , second: `temporalNode`.datetime.second , millisecond: `temporalNode`.datetime.millisecond , microsecond: `temporalNode`.datetime.microsecond , nanosecond: `temporalNode`.datetime.nanosecond , timezone: `temporalNode`.datetime.timezone , formatted: toString(`temporalNode`.datetime) },temporalNodes: [sortedElement IN apoc.coll.sortMulti([(`temporalNode`)-[:`TEMPORAL`]->(`temporalNode_temporalNodes`:`TemporalNode`) | temporalNode_temporalNodes {_id: ID(`temporalNode_temporalNodes`),datetime: `temporalNode_temporalNodes`.datetime,time: `temporalNode_temporalNodes`.time,temporalNodes: [sortedElement IN apoc.coll.sortMulti([(`temporalNode_temporalNodes`)-[:`TEMPORAL`]->(`temporalNode_temporalNodes_temporalNodes`:`TemporalNode`) | temporalNode_temporalNodes_temporalNodes {_id: ID(`temporalNode_temporalNodes_temporalNodes`),datetime: `temporalNode_temporalNodes_temporalNodes`.datetime,time: `temporalNode_temporalNodes_temporalNodes`.time}], ['datetime','time']) | sortedElement { .*, datetime: {year: sortedElement.datetime.year,formatted: toString(sortedElement.datetime)},time: {hour: sortedElement.time.hour}}][1..3] }], ['^datetime']) | sortedElement { .*, datetime: {year: sortedElement.datetime.year,month: sortedElement.datetime.month,day: sortedElement.datetime.day,hour: sortedElement.datetime.hour,minute: sortedElement.datetime.minute,second: sortedElement.datetime.second,millisecond: sortedElement.datetime.millisecond,microsecond: sortedElement.datetime.microsecond,nanosecond: sortedElement.datetime.nanosecond,timezone: sortedElement.datetime.timezone,formatted: toString(sortedElement.datetime)},time: {hour: sortedElement.time.hour}}] } AS `temporalNode` ORDER BY temporalNode.datetime DESC SKIP $offset";

t.plan(1);
return Promise.all([
Expand Down

0 comments on commit 4d3ef38

Please sign in to comment.