Skip to content

Commit af9b2fa

Browse files
authored
Add missing JavaDoc (#180)
resolves #58
1 parent 67b9019 commit af9b2fa

15 files changed

+76
-2
lines changed

core/src/main/kotlin/org/neo4j/graphql/SchemaBuilder.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import org.neo4j.graphql.handler.relation.CreateRelationHandler
1515
import org.neo4j.graphql.handler.relation.CreateRelationTypeHandler
1616
import org.neo4j.graphql.handler.relation.DeleteRelationHandler
1717

18+
/**
19+
* Contains factory methods to generate an augmented graphql schema
20+
*/
1821
object SchemaBuilder {
1922

2023
/**
@@ -31,6 +34,12 @@ object SchemaBuilder {
3134
return buildSchema(typeDefinitionRegistry, config, dataFetchingInterceptor)
3235
}
3336

37+
/**
38+
* @param typeDefinitionRegistry a registry containing all the types, that should be augmented
39+
* @param config defines how the schema should get augmented
40+
* @param dataFetchingInterceptor since this library registers dataFetcher for its augmented methods, these data
41+
* fetchers may be called by other resolver. This interceptor will let you convert a cypher query into real data.
42+
*/
3443
@JvmStatic
3544
@JvmOverloads
3645
fun buildSchema(typeDefinitionRegistry: TypeDefinitionRegistry, config: SchemaConfig = SchemaConfig(), dataFetchingInterceptor: DataFetchingInterceptor? = null): GraphQLSchema {

core/src/main/kotlin/org/neo4j/graphql/handler/BaseDataFetcher.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import org.neo4j.graphql.Cypher
1111
import org.neo4j.graphql.aliasOrName
1212
import org.neo4j.graphql.handler.projection.ProjectionBase
1313

14+
/**
15+
* The is a base class for the implementation of graphql data fetcher used in this project
16+
*/
1417
abstract class BaseDataFetcher(val fieldDefinition: GraphQLFieldDefinition) : ProjectionBase(), DataFetcher<Cypher> {
1518

1619
override fun get(env: DataFetchingEnvironment?): Cypher {

core/src/main/kotlin/org/neo4j/graphql/handler/BaseDataFetcherForContainer.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import org.neo4j.cypherdsl.core.*
99
import org.neo4j.cypherdsl.core.Cypher.*
1010
import org.neo4j.graphql.*
1111

12+
/**
13+
* This is a base class for all Node or Relation related data fetcher.
14+
*/
1215
abstract class BaseDataFetcherForContainer(
1316
val type: GraphQLFieldsContainer,
1417
fieldDefinition: GraphQLFieldDefinition

core/src/main/kotlin/org/neo4j/graphql/handler/CreateTypeHandler.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import org.neo4j.cypherdsl.core.Statement
66
import org.neo4j.cypherdsl.core.StatementBuilder
77
import org.neo4j.graphql.*
88

9+
/**
10+
* This class handles all the logic related to the creation of nodes.
11+
* This includes the augmentation of the create&lt;Node&gt;-mutator and the related cypher generation
12+
*/
913
class CreateTypeHandler private constructor(
1014
type: GraphQLFieldsContainer,
1115
fieldDefinition: GraphQLFieldDefinition

core/src/main/kotlin/org/neo4j/graphql/handler/CypherDirectiveHandler.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import org.neo4j.cypherdsl.core.Functions
99
import org.neo4j.cypherdsl.core.Statement
1010
import org.neo4j.graphql.*
1111

12+
/**
13+
* This class handles all logic related to custom Cypher queries declared by fields with a @cypher directive
14+
*/
1215
class CypherDirectiveHandler(
1316
private val type: GraphQLFieldsContainer?,
1417
private val isQuery: Boolean,

core/src/main/kotlin/org/neo4j/graphql/handler/DeleteHandler.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import org.neo4j.cypherdsl.core.Statement
88
import org.neo4j.cypherdsl.core.StatementBuilder.OngoingUpdate
99
import org.neo4j.graphql.*
1010

11+
/**
12+
* This class handles all the logic related to the deletion of nodes.
13+
* This includes the augmentation of the delete&lt;Node&gt;-mutator and the related cypher generation
14+
*/
1115
class DeleteHandler private constructor(
1216
type: GraphQLFieldsContainer,
1317
private val idField: GraphQLFieldDefinition,

core/src/main/kotlin/org/neo4j/graphql/handler/MergeOrUpdateHandler.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ import org.neo4j.cypherdsl.core.Statement
1111
import org.neo4j.cypherdsl.core.StatementBuilder.OngoingMatchAndUpdate
1212
import org.neo4j.graphql.*
1313

14+
/**
15+
* This class handles all the logic related to the updating of nodes.
16+
* This includes the augmentation of the update&lt;Node&gt; and merge&lt;Node&gt;-mutator and the related cypher generation
17+
*/
1418
class MergeOrUpdateHandler private constructor(
1519
type: GraphQLFieldsContainer,
1620
private val merge: Boolean,

core/src/main/kotlin/org/neo4j/graphql/handler/QueryHandler.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import org.neo4j.cypherdsl.core.Statement
88
import org.neo4j.graphql.*
99
import org.neo4j.graphql.handler.filter.OptimizedFilterHandler
1010

11+
/**
12+
* This class handles all the logic related to the querying of nodes and relations.
13+
* This includes the augmentation of the query-fields and the related cypher generation
14+
*/
1115
class QueryHandler private constructor(
1216
type: GraphQLFieldsContainer,
1317
fieldDefinition: GraphQLFieldDefinition)

core/src/main/kotlin/org/neo4j/graphql/handler/filter/OptimizedFilterHandler.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ typealias WhereClauseFactory = (
2424

2525
typealias ConditionBuilder = (ExposesWith) -> OrderableOngoingReadingAndWithWithoutWhere
2626

27+
/**
28+
* This its a specialized handler that uses an alternative approach for filtering. By using multiple MATCH clauses,
29+
* this can facilitate the use of optimizations within the neo4j database, which can lead to significant performance
30+
* improvements for large data sets.
31+
*
32+
* If this handler cannot generate an optimization for the passed filter, an [OptimizedQueryException] will be
33+
* thrown, so the calling site can fall back to the non-optimized logic
34+
*/
2735
class OptimizedFilterHandler(val type: GraphQLFieldsContainer) : ProjectionBase() {
2836

2937
fun generateFilterQuery(variable: String, fieldDefinition: GraphQLFieldDefinition, field: Field, readingWithoutWhere: OngoingReadingWithoutWhere, rootNode: PropertyContainer): OngoingReading {

core/src/main/kotlin/org/neo4j/graphql/handler/projection/ProjectionBase.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import org.neo4j.graphql.parser.ParsedQuery
1515
import org.neo4j.graphql.parser.QueryParser.parseArguments
1616
import org.neo4j.graphql.parser.QueryParser.parseFilter
1717

18-
18+
/**
19+
* This class contains the logic for projecting nodes and relations
20+
*/
1921
open class ProjectionBase {
2022
companion object {
2123
const val NATIVE_ID = "_id"

core/src/main/kotlin/org/neo4j/graphql/handler/relation/BaseRelationHandler.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import org.neo4j.cypherdsl.core.Node
88
import org.neo4j.graphql.*
99
import org.neo4j.graphql.handler.BaseDataFetcherForContainer
1010

11+
/**
12+
* This is a base class for all handler acting on relations / edges
13+
*/
1114
abstract class BaseRelationHandler(
1215
type: GraphQLFieldsContainer,
1316
val relation: RelationshipInfo,

core/src/main/kotlin/org/neo4j/graphql/handler/relation/CreateRelationHandler.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import org.neo4j.cypherdsl.core.Statement
99
import org.neo4j.cypherdsl.core.StatementBuilder.OngoingUpdate
1010
import org.neo4j.graphql.*
1111

12+
/**
13+
* This class handles all the logic related to the creation of relations starting from an existing node.
14+
* This includes the augmentation of the add&lt;Edge&gt;-mutator and the related cypher generation
15+
*/
1216
class CreateRelationHandler private constructor(
1317
type: GraphQLFieldsContainer,
1418
relation: RelationshipInfo,

core/src/main/kotlin/org/neo4j/graphql/handler/relation/CreateRelationTypeHandler.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import org.neo4j.cypherdsl.core.Statement
77
import org.neo4j.cypherdsl.core.StatementBuilder
88
import org.neo4j.graphql.*
99

10+
/**
11+
* This class handles all the logic related to the creation of relations.
12+
* This includes the augmentation of the create&lt;Edge&gt;-mutator and the related cypher generation
13+
*/
1014
class CreateRelationTypeHandler private constructor(
1115
type: GraphQLFieldsContainer,
1216
relation: RelationshipInfo,

core/src/main/kotlin/org/neo4j/graphql/handler/relation/DeleteRelationHandler.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import org.neo4j.cypherdsl.core.Statement
99
import org.neo4j.cypherdsl.core.StatementBuilder
1010
import org.neo4j.graphql.*
1111

12+
/**
13+
* This class handles all the logic related to the deletion of relations starting from an existing node.
14+
* This includes the augmentation of the delete&lt;Edge&gt;-mutator and the related cypher generation
15+
*/
1216
class DeleteRelationHandler private constructor(
1317
type: GraphQLFieldsContainer,
1418
relation: RelationshipInfo,

core/src/main/kotlin/org/neo4j/graphql/parser/QueryParser.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import org.neo4j.graphql.handler.projection.ProjectionBase
1111

1212
typealias CypherDSL = org.neo4j.cypherdsl.core.Cypher
1313

14+
/**
15+
* An internal representation of all the filtering passed to an graphql field
16+
*/
1417
class ParsedQuery(
1518
val fieldPredicates: List<FieldPredicate>,
1619
val relationPredicates: List<RelationPredicate>,
@@ -31,6 +34,9 @@ abstract class Predicate<T>(
3134
val normalizedName: String,
3235
val index: Int)
3336

37+
/**
38+
* Predicates on a nodes' or relations' property
39+
*/
3440
class FieldPredicate(
3541
op: FieldOperator,
3642
queryField: ObjectField,
@@ -50,6 +56,10 @@ class FieldPredicate(
5056

5157
}
5258

59+
/**
60+
* Predicate for a relation
61+
*/
62+
5363
class RelationPredicate(
5464
type: GraphQLFieldsContainer,
5565
op: RelationOperator,
@@ -78,7 +88,9 @@ class RelationPredicate(
7888

7989
object QueryParser {
8090

81-
91+
/**
92+
* This parser takes an filter object an transform it to the internal [ParsedQuery]-representation
93+
*/
8294
fun parseFilter(objectValue: ObjectValue, type: GraphQLFieldsContainer): ParsedQuery {
8395
// Map of all queried fields
8496
// we remove all matching fields from this map, so we can ensure that only known fields got queried
@@ -99,6 +111,9 @@ object QueryParser {
99111
return createParsedQuery(queriedFields, type, null, or, and)
100112
}
101113

114+
/**
115+
* This parser takes all non-filter arguments of a graphql-field an transform it to the internal [ParsedQuery]-representation
116+
*/
102117
fun parseArguments(arguments: List<Argument>, fieldDefinition: GraphQLFieldDefinition, type: GraphQLFieldsContainer): ParsedQuery {
103118
// TODO we should check if the argument is defined on the field definition and throw an error otherwise
104119
// Map of all queried fields

0 commit comments

Comments
 (0)