-
Notifications
You must be signed in to change notification settings - Fork 49
Rely on GraphQL-Schema instead of Schema-Definitions #62
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
Conversation
| </executions> | ||
| <configuration> | ||
| <includes> | ||
| <!-- TODO what to do with this part? --> |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
| var type = field.type as GraphQLType | ||
| type = getInputType(type) | ||
| type = if (forceOptionalProvider.invoke(field)) { | ||
| (type as? GraphQLNonNull)?.wrappedType ?: type |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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)
jexp
left a comment
There was a problem hiding this 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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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")) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)) { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extension method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simplify
I questioned the whole
FieldDefinitionvsGraphQLFieldDefinitionand came to the conclusion thatGraphQLFieldDefinitionshould be the entity on which all enhancements rely on.I have refactored everything to that effect again.