File tree Expand file tree Collapse file tree 8 files changed +148
-127
lines changed
main/kotlin/org/neo4j/graphql
test/resources/tck-test-files Expand file tree Collapse file tree 8 files changed +148
-127
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 (
@@ -144,7 +145,7 @@ class BuildingEnv(
144
145
optionsTypeBuilder.field(GraphQLInputObjectField .newInputObjectField()
145
146
.name(ProjectionBase .SORT )
146
147
.type(GraphQLList (GraphQLNonNull (GraphQLTypeReference (sortTypeName))))
147
- .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." )
148
+ .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." )
148
149
.build())
149
150
}
150
151
optionsTypeBuilder.field(GraphQLInputObjectField .newInputObjectField()
Original file line number Diff line number Diff line change @@ -9,6 +9,11 @@ data class SchemaConfig @JvmOverloads constructor(
9
9
*/
10
10
val capitalizeQueryFields : Boolean = false ,
11
11
12
+ /* *
13
+ * if true, the generated fields for query or mutation will use the plural of the types name
14
+ */
15
+ val pluralizeFields : Boolean = false ,
16
+
12
17
/* *
13
18
* Defines the way the input for queries and mutations are generated
14
19
*/
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.*
@@ -34,9 +35,13 @@ class QueryHandler private constructor(
34
35
input(FILTER , GraphQLTypeReference (filterTypeName))
35
36
}
36
37
38
+ var fieldName = if (schemaConfig.capitalizeQueryFields) typeName else typeName.decapitalize()
39
+ if (schemaConfig.pluralizeFields) {
40
+ fieldName = English .plural(fieldName)
41
+ }
37
42
val builder = GraphQLFieldDefinition
38
43
.newFieldDefinition()
39
- .name(if (schemaConfig.capitalizeQueryFields) typeName else typeName.decapitalize() )
44
+ .name(fieldName )
40
45
.arguments(arguments)
41
46
.type(GraphQLNonNull (GraphQLList (GraphQLNonNull (GraphQLTypeReference (type.name)))))
42
47
You can’t perform that action at this time.
0 commit comments