Skip to content

Add missing JavaDoc #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions core/src/main/kotlin/org/neo4j/graphql/SchemaBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import org.neo4j.graphql.handler.relation.CreateRelationHandler
import org.neo4j.graphql.handler.relation.CreateRelationTypeHandler
import org.neo4j.graphql.handler.relation.DeleteRelationHandler

/**
* Contains factory methods to generate an augmented graphql schema
*/
object SchemaBuilder {

/**
Expand All @@ -31,6 +34,12 @@ object SchemaBuilder {
return buildSchema(typeDefinitionRegistry, config, dataFetchingInterceptor)
}

/**
* @param typeDefinitionRegistry a registry containing all the types, that should be augmented
* @param config defines how the schema should get augmented
* @param dataFetchingInterceptor since this library registers dataFetcher for its augmented methods, these data
* fetchers may be called by other resolver. This interceptor will let you convert a cypher query into real data.
*/
@JvmStatic
@JvmOverloads
fun buildSchema(typeDefinitionRegistry: TypeDefinitionRegistry, config: SchemaConfig = SchemaConfig(), dataFetchingInterceptor: DataFetchingInterceptor? = null): GraphQLSchema {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import org.neo4j.graphql.Cypher
import org.neo4j.graphql.aliasOrName
import org.neo4j.graphql.handler.projection.ProjectionBase

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

override fun get(env: DataFetchingEnvironment?): Cypher {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import org.neo4j.cypherdsl.core.*
import org.neo4j.cypherdsl.core.Cypher.*
import org.neo4j.graphql.*

/**
* This is a base class for all Node or Relation related data fetcher.
*/
abstract class BaseDataFetcherForContainer(
val type: GraphQLFieldsContainer,
fieldDefinition: GraphQLFieldDefinition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import org.neo4j.cypherdsl.core.Statement
import org.neo4j.cypherdsl.core.StatementBuilder
import org.neo4j.graphql.*

/**
* This class handles all the logic related to the creation of nodes.
* This includes the augmentation of the create&lt;Node&gt;-mutator and the related cypher generation
*/
class CreateTypeHandler private constructor(
type: GraphQLFieldsContainer,
fieldDefinition: GraphQLFieldDefinition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import org.neo4j.cypherdsl.core.Functions
import org.neo4j.cypherdsl.core.Statement
import org.neo4j.graphql.*

/**
* This class handles all logic related to custom Cypher queries declared by fields with a @cypher directive
*/
class CypherDirectiveHandler(
private val type: GraphQLFieldsContainer?,
private val isQuery: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import org.neo4j.cypherdsl.core.Statement
import org.neo4j.cypherdsl.core.StatementBuilder.OngoingUpdate
import org.neo4j.graphql.*

/**
* This class handles all the logic related to the deletion of nodes.
* This includes the augmentation of the delete&lt;Node&gt;-mutator and the related cypher generation
*/
class DeleteHandler private constructor(
type: GraphQLFieldsContainer,
private val idField: GraphQLFieldDefinition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import org.neo4j.cypherdsl.core.Statement
import org.neo4j.cypherdsl.core.StatementBuilder.OngoingMatchAndUpdate
import org.neo4j.graphql.*

/**
* This class handles all the logic related to the updating of nodes.
* This includes the augmentation of the update&lt;Node&gt; and merge&lt;Node&gt;-mutator and the related cypher generation
*/
class MergeOrUpdateHandler private constructor(
type: GraphQLFieldsContainer,
private val merge: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import org.neo4j.cypherdsl.core.Statement
import org.neo4j.graphql.*
import org.neo4j.graphql.handler.filter.OptimizedFilterHandler

/**
* This class handles all the logic related to the querying of nodes and relations.
* This includes the augmentation of the query-fields and the related cypher generation
*/
class QueryHandler private constructor(
type: GraphQLFieldsContainer,
fieldDefinition: GraphQLFieldDefinition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ typealias WhereClauseFactory = (

typealias ConditionBuilder = (ExposesWith) -> OrderableOngoingReadingAndWithWithoutWhere

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

fun generateFilterQuery(variable: String, field: Field, readingWithoutWhere: OngoingReadingWithoutWhere, rootNode: PropertyContainer): OngoingReading {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import org.neo4j.graphql.parser.ParsedQuery
import org.neo4j.graphql.parser.QueryParser.parseArguments
import org.neo4j.graphql.parser.QueryParser.parseFilter


/**
* This class contains the logic for projecting nodes and relations
*/
open class ProjectionBase {
companion object {
const val NATIVE_ID = "_id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import org.neo4j.cypherdsl.core.Node
import org.neo4j.graphql.*
import org.neo4j.graphql.handler.BaseDataFetcherForContainer

/**
* This is a base class for all handler acting on relations / edges
*/
abstract class BaseRelationHandler(
type: GraphQLFieldsContainer,
val relation: RelationshipInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import org.neo4j.cypherdsl.core.Statement
import org.neo4j.cypherdsl.core.StatementBuilder.OngoingUpdate
import org.neo4j.graphql.*

/**
* This class handles all the logic related to the creation of relations starting from an existing node.
* This includes the augmentation of the add&lt;Edge&gt;-mutator and the related cypher generation
*/
class CreateRelationHandler private constructor(
type: GraphQLFieldsContainer,
relation: RelationshipInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import org.neo4j.cypherdsl.core.Statement
import org.neo4j.cypherdsl.core.StatementBuilder
import org.neo4j.graphql.*

/**
* This class handles all the logic related to the creation of relations.
* This includes the augmentation of the create&lt;Edge&gt;-mutator and the related cypher generation
*/
class CreateRelationTypeHandler private constructor(
type: GraphQLFieldsContainer,
relation: RelationshipInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import org.neo4j.cypherdsl.core.Statement
import org.neo4j.cypherdsl.core.StatementBuilder
import org.neo4j.graphql.*

/**
* This class handles all the logic related to the deletion of relations starting from an existing node.
* This includes the augmentation of the delete&lt;Edge&gt;-mutator and the related cypher generation
*/
class DeleteRelationHandler private constructor(
type: GraphQLFieldsContainer,
relation: RelationshipInfo,
Expand Down
17 changes: 16 additions & 1 deletion core/src/main/kotlin/org/neo4j/graphql/parser/QueryParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import org.neo4j.graphql.handler.projection.ProjectionBase

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

/**
* An internal representation of all the filtering passed to an graphql field
*/
class ParsedQuery(
val fieldPredicates: List<FieldPredicate>,
val relationPredicates: List<RelationPredicate>,
Expand All @@ -31,6 +34,9 @@ abstract class Predicate<T>(
val normalizedName: String,
val index: Int)

/**
* Predicates on a nodes' or relations' property
*/
class FieldPredicate(
op: FieldOperator,
queryField: ObjectField,
Expand All @@ -50,6 +56,10 @@ class FieldPredicate(

}

/**
* Predicate for a relation
*/

class RelationPredicate(
type: GraphQLFieldsContainer,
op: RelationOperator,
Expand Down Expand Up @@ -77,7 +87,9 @@ class RelationPredicate(

object QueryParser {


/**
* This parser takes an filter object an transform it to the internal [ParsedQuery]-representation
*/
fun parseFilter(objectValue: ObjectValue, type: GraphQLFieldsContainer): ParsedQuery {
// Map of all queried fields
// we remove all matching fields from this map, so we can ensure that only known fields got queried
Expand All @@ -98,6 +110,9 @@ object QueryParser {
return createParsedQuery(queriedFields, type, null, or, and)
}

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