Skip to content

Conversation

@Andy2003
Copy link
Collaborator

I questioned the whole FieldDefinition vs GraphQLFieldDefinition and came to the conclusion that GraphQLFieldDefinition should be the entity on which all enhancements rely on.
I have refactored everything to that effect again.

</executions>
<configuration>
<includes>
<!-- TODO what to do with this part? -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good question, need to check. I guess we just copied that from somewhere for maven central release.

const val MUTATION = "Mutation"
}

abstract fun augmentType(type: GraphQLFieldsContainer, buildingEnv: BuildingEnv)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this have to be abstract?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this class is the blueprint of a Handler: yes

Copy link
Contributor

@jexp jexp Sep 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this method was not abstract the handler could be handled by a closure


abstract fun createDataFetcher(rootType: GraphQLObjectType, fieldDefinition: GraphQLFieldDefinition): DataFetcher<Cypher>?

fun input(name: String, type: GraphQLType): GraphQLArgument {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the right place for this function? we have similar things in other places.

# Conflicts:
#	src/main/kotlin/org/neo4j/graphql/Cypher.kt
#	src/main/kotlin/org/neo4j/graphql/SchemaBuilder.kt
#	src/test/kotlin/DataFetcherInterceptorDemo.kt
@Andy2003 Andy2003 requested a review from jexp September 23, 2019 06:37
var type = field.type as GraphQLType
type = getInputType(type)
type = if (forceOptionalProvider.invoke(field)) {
(type as? GraphQLNonNull)?.wrappedType ?: type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't there be an extension function for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it is operation on a list, I don't see the right cutting point here to extract the function as extension function.

return relevantFields.map { field ->
var type = field.type as GraphQLType
type = getInputType(type)
type = if (forceOptionalProvider.invoke(field)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just use the call syntax forceOptionalProvider(field)

Copy link
Contributor

@jexp jexp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments.

val rootType = types[rootTypeName]
types[rootTypeName] = if (rootType == null) {
val builder = GraphQLObjectType.newObject()
builder.name(rootTypeName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should it also be added to types ?
if not multiple calls to this method would create the root type several times

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the assignment is in line 50

.build()
} else {
val existingRootType = (rootType as? GraphQLObjectType
?: throw IllegalStateException("root type $rootTypeName is not an object type"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should report what it actually is

val existingRootType = (rootType as? GraphQLObjectType
?: throw IllegalStateException("root type $rootTypeName is not an object type"))
if (existingRootType.getFieldDefinition(fieldDefinition.name) != null) {
return // definition already exists
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but is it the same?

if (existingRootType.getFieldDefinition(fieldDefinition.name) != null) {
return // definition already exists
}
existingRootType
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this create a new type or do an in place update?
in the former case we need to replace it in types map

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the assignment is in line 50


fun addFilterType(type: GraphQLFieldsContainer, handled: MutableSet<String> = mutableSetOf()): String {
val filterName = "_${type.name}Filter"
if (handled.contains(filterName)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handled? better name

?.let { types[it.inputDefinition] } as? GraphQLInputType
?: throw IllegalArgumentException("Cannot find input type for ${inner.name}")
}
return type as? GraphQLInputType
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't have been returned then already in the first if?

return
}
val typeName = type.name()
val idField = type.fieldDefinitions.find { it.isID() } ?: return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extension method?

.type(TypeName(typeName))
val fieldDefinition = buildingEnv
.buildFieldDefinition("delete", type, listOf(idField), nullableResult = true)
.description("Deletes ${type.name} and returns its ID on successful deletion")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't return the id but the type itself.

if (!canHandle(type)) {
return null
}
val idField = type.fieldDefinitions.find { it.isID() } ?: return null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extension method

if (!schemaConfig.mutation.enabled || schemaConfig.mutation.exclude.contains(typeName)) {
return false
}
if (type.fieldDefinitions.find { it.isID() } == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extension method

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplify

@jexp jexp merged commit 0ab80bb into neo4j-graphql:master Oct 28, 2019
@Andy2003 Andy2003 deleted the feature/work-on-schema branch October 28, 2019 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants