File tree Expand file tree Collapse file tree 8 files changed +173
-129
lines changed
main/kotlin/org/neo4j/graphql
test/resources/tck-test-files Expand file tree Collapse file tree 8 files changed +173
-129
lines changed Original file line number Diff line number Diff line change 39
39
<artifactId >graphql-java</artifactId >
40
40
<version >15.0</version >
41
41
</dependency >
42
+ <dependency >
43
+ <groupId >org.atteo</groupId >
44
+ <artifactId >evo-inflector</artifactId >
45
+ <version >1.2.2</version >
46
+ </dependency >
47
+
42
48
<dependency >
43
49
<groupId >org.junit.jupiter</groupId >
44
50
<artifactId >junit-jupiter</artifactId >
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package org.neo4j.graphql
2
2
3
3
import graphql.Scalars
4
4
import graphql.schema.*
5
+ import org.atteo.evo.inflector.English
5
6
import org.neo4j.graphql.handler.projection.ProjectionBase
6
7
7
8
class BuildingEnv (
@@ -143,7 +144,7 @@ class BuildingEnv(
143
144
optionsTypeBuilder.field(GraphQLInputObjectField .newInputObjectField()
144
145
.name(ProjectionBase .SORT )
145
146
.type(GraphQLList (GraphQLNonNull (GraphQLTypeReference (sortTypeName))))
146
- .description(" Specify one or more $sortTypeName objects to sort ${type.name} s by. The sorts will be applied in the order in which they are arranged in the array." )
147
+ .description(" Specify one or more $sortTypeName objects to sort ${English .plural( type.name)} by. The sorts will be applied in the order in which they are arranged in the array." )
147
148
.build())
148
149
}
149
150
optionsTypeBuilder.field(GraphQLInputObjectField .newInputObjectField()
Original file line number Diff line number Diff line change @@ -7,6 +7,12 @@ data class SchemaConfig @JvmOverloads constructor(
7
7
* if true, the top level fields of the Query-type will be capitalized
8
8
*/
9
9
val capitalizeQueryFields : Boolean = false ,
10
+
11
+ /* *
12
+ * if true, the generated fields for query or mutation will use the plural of the types name
13
+ */
14
+ val pluralizeFields : Boolean = false ,
15
+
10
16
/* *
11
17
* Defines the way the input for queries and mutations are generated
12
18
*/
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package org.neo4j.graphql.handler
3
3
import graphql.Scalars
4
4
import graphql.language.Field
5
5
import graphql.schema.*
6
+ import org.atteo.evo.inflector.English
6
7
import org.neo4j.cypherdsl.core.Cypher.*
7
8
import org.neo4j.cypherdsl.core.Statement
8
9
import org.neo4j.graphql.*
@@ -29,9 +30,13 @@ class QueryHandler private constructor(
29
30
buildingEnv.addInputType(" _${typeName} Input" , type.relevantFields())
30
31
val filterTypeName = buildingEnv.addFilterType(type)
31
32
33
+ var fieldName = if (schemaConfig.capitalizeQueryFields) typeName else typeName.decapitalize()
34
+ if (schemaConfig.pluralizeFields) {
35
+ fieldName = English .plural(fieldName)
36
+ }
32
37
val builder = GraphQLFieldDefinition
33
38
.newFieldDefinition()
34
- .name(if (schemaConfig.capitalizeQueryFields) typeName else typeName.decapitalize() )
39
+ .name(fieldName )
35
40
.arguments(buildingEnv.getInputValueDefinitions(relevantFields) { true })
36
41
.argument(input(FILTER , GraphQLTypeReference (filterTypeName)))
37
42
.type(GraphQLNonNull (GraphQLList (GraphQLNonNull (GraphQLTypeReference (type.name)))))
You can’t perform that action at this time.
0 commit comments