diff --git a/kobby-generator-kotlin/src/test/kotlin/io/github/ermadmi78/kobby/generator/kotlin/SchemaValidationTest.kt b/kobby-generator-kotlin/src/test/kotlin/io/github/ermadmi78/kobby/generator/kotlin/SchemaValidationTest.kt index 891b3921..28b0dc6d 100644 --- a/kobby-generator-kotlin/src/test/kotlin/io/github/ermadmi78/kobby/generator/kotlin/SchemaValidationTest.kt +++ b/kobby-generator-kotlin/src/test/kotlin/io/github/ermadmi78/kobby/generator/kotlin/SchemaValidationTest.kt @@ -9,6 +9,7 @@ import io.github.ermadmi78.kobby.model.parseSchema import org.junit.jupiter.api.Test import java.io.InputStreamReader import kotlin.test.assertEquals +import kotlin.test.assertTrue import kotlin.test.fail /** @@ -19,7 +20,7 @@ import kotlin.test.fail class SchemaValidationTest { private val layout = KotlinLayout( KotlinTypes.PREDEFINED_SCALARS + mapOf( - "DateTime" to KotlinType("java.time", "OffsetDateTime"), + "Date" to KotlinType("java.time", "LocalDate"), "JSON" to MAP.parameterize(STRING, ANY.nullable()) ), KotlinContextLayout( @@ -100,6 +101,11 @@ class SchemaValidationTest { emptyMap(), InputStreamReader(this.javaClass.getResourceAsStream("kobby.graphqls")!!) ) + + schema.validate().forEach { + println(it) + } + val files = generateKotlin(schema, layout) files.forEach { @@ -116,6 +122,8 @@ class SchemaValidationTest { InputStreamReader(this.javaClass.getResourceAsStream("unknown_scalar.graphqls.txt")!!) ) + assertTrue(schema.validate().isEmpty()) + val expected = "Kotlin data type for scalar 'DummyScalar' not found. " + "Please, configure it by means of 'kobby' extension. https://github.com/ermadmi78/kobby" try { @@ -133,6 +141,8 @@ class SchemaValidationTest { InputStreamReader(this.javaClass.getResourceAsStream("unknown_type.graphqls.txt")!!) ) + assertTrue(schema.validate().isEmpty()) + val expected = "Unknown type \"DummyType\"" try { generateKotlin(schema, layout) @@ -149,6 +159,8 @@ class SchemaValidationTest { InputStreamReader(this.javaClass.getResourceAsStream("unknown_arg_type.graphqls.txt")!!) ) + assertTrue(schema.validate().isEmpty()) + val expected = "Unknown type \"DummyArg\"" try { generateKotlin(schema, layout) @@ -165,6 +177,8 @@ class SchemaValidationTest { InputStreamReader(this.javaClass.getResourceAsStream("unknown_parent.graphqls.txt")!!) ) + assertTrue(schema.validate().isEmpty()) + val expected = "Unknown type \"DummyParent\"" try { generateKotlin(schema, layout) @@ -173,4 +187,20 @@ class SchemaValidationTest { assertEquals(expected, e.message) } } + + @Test + fun testUnknownParentWithDefault() { + val schema = parseSchema( + emptyMap(), + InputStreamReader(this.javaClass.getResourceAsStream("unknown_parent_with_default.graphqls.txt")!!) + ) + + val expected = "Unknown type \"DummyParentWithDefault\"" + try { + schema.validate() + fail("Must throw: $expected") + } catch (e: KobbyInvalidSchemaException) { + assertEquals(expected, e.message) + } + } } \ No newline at end of file diff --git a/kobby-generator-kotlin/src/test/resources/io/github/ermadmi78/kobby/generator/kotlin/unknown_parent_with_default.graphqls.txt b/kobby-generator-kotlin/src/test/resources/io/github/ermadmi78/kobby/generator/kotlin/unknown_parent_with_default.graphqls.txt new file mode 100644 index 00000000..1045f644 --- /dev/null +++ b/kobby-generator-kotlin/src/test/resources/io/github/ermadmi78/kobby/generator/kotlin/unknown_parent_with_default.graphqls.txt @@ -0,0 +1,9 @@ +directive @default on FIELD_DEFINITION + +type Query { + temp: Film +} + +type Film implements DummyParentWithDefault { + title: String! @default +} \ No newline at end of file diff --git a/kobby-gradle-plugin/src/main/kotlin/io/github/ermadmi78/kobby/task/KobbyKotlin.kt b/kobby-gradle-plugin/src/main/kotlin/io/github/ermadmi78/kobby/task/KobbyKotlin.kt index f1acdf19..1ca472fa 100644 --- a/kobby-gradle-plugin/src/main/kotlin/io/github/ermadmi78/kobby/task/KobbyKotlin.kt +++ b/kobby-gradle-plugin/src/main/kotlin/io/github/ermadmi78/kobby/task/KobbyKotlin.kt @@ -924,6 +924,14 @@ open class KobbyKotlin : DefaultTask() { "Schema parsing failed.".throwIt(e) } + try { + schema.validate().forEach { warning -> + logger.warn(warning) + } + } catch (e: Exception) { + "Schema validation failed.".throwIt(e) + } + val output = try { generateKotlin(schema, layout) } catch (e: Exception) { diff --git a/kobby-maven-plugin/src/main/kotlin/io/github/ermadmi78/kobby/GenerateKotlinMojo.kt b/kobby-maven-plugin/src/main/kotlin/io/github/ermadmi78/kobby/GenerateKotlinMojo.kt index 86752750..dc23928a 100644 --- a/kobby-maven-plugin/src/main/kotlin/io/github/ermadmi78/kobby/GenerateKotlinMojo.kt +++ b/kobby-maven-plugin/src/main/kotlin/io/github/ermadmi78/kobby/GenerateKotlinMojo.kt @@ -290,6 +290,14 @@ class GenerateKotlinMojo : AbstractMojo() { "Schema parsing failed.".throwIt(e) } + try { + schema.validate().forEach { warning -> + log.warn(warning) + } + } catch (e: Exception) { + "Schema validation failed.".throwIt(e) + } + val output = try { generateKotlin(schema, layout) } catch (e: Exception) { diff --git a/kobby-model/build.gradle.kts b/kobby-model/build.gradle.kts index 54eca996..a23f660e 100644 --- a/kobby-model/build.gradle.kts +++ b/kobby-model/build.gradle.kts @@ -34,4 +34,8 @@ tasks { minimize() configurations = listOf(shadowImplementation) } + + test { + dependsOn(":resolveIntegrationTestDependencies") + } } diff --git a/kobby-model/src/main/kotlin/io/github/ermadmi78/kobby/model/KobbyField.kt b/kobby-model/src/main/kotlin/io/github/ermadmi78/kobby/model/KobbyField.kt index 734544cc..a0e511f9 100644 --- a/kobby-model/src/main/kotlin/io/github/ermadmi78/kobby/model/KobbyField.kt +++ b/kobby-model/src/main/kotlin/io/github/ermadmi78/kobby/model/KobbyField.kt @@ -62,6 +62,85 @@ class KobbyField internal constructor( node.isOperation || (overriddenField?.isResolve ?: (resolve || arguments.isNotEmpty())) } + internal fun validate(warnings: MutableList) { + if (!primaryKey && !required && !default && !selection && !resolve) { + return + } + val topOverriddenField = findTopOverriddenField(node) + + var counter = 0 + if (primaryKey) { + counter++ + warnings.addPropertyWarning(KobbyDirective.PRIMARY_KEY) + topOverriddenField?.takeIf { !it.primaryKey }?.also { + warnings.addOverriddenWarning(KobbyDirective.PRIMARY_KEY, it) + } + } + + if (required) { + counter++ + warnings.addPropertyWarning(KobbyDirective.REQUIRED) + topOverriddenField?.takeIf { !it.required }?.also { + warnings.addOverriddenWarning(KobbyDirective.REQUIRED, it) + } + } + + if (default) { + counter++ + warnings.addPropertyWarning(KobbyDirective.DEFAULT) + topOverriddenField?.takeIf { !it.default }?.also { + warnings.addOverriddenWarning(KobbyDirective.DEFAULT, it) + } + } + + if (counter > 1) { + warnings += "Restriction violated [${node.name}.$name]: " + + "The field is marked with several directives at once - " + + "@${KobbyDirective.DEFAULT}, @${KobbyDirective.REQUIRED}, @${KobbyDirective.PRIMARY_KEY}, " + + "the behavior of the Kobby Plugin is undefined!" + } + + if (selection) { + if (!arguments.values.any { it.isInitialized }) { + warnings += "Restriction violated [${node.name}.$name]: " + + "The @${KobbyDirective.SELECTION} directive can only be applied to a field that " + + "contains optional arguments - nullable arguments or arguments with default value." + } + topOverriddenField?.takeIf { !it.selection }?.also { + warnings.addOverriddenWarning(KobbyDirective.SELECTION, it) + } + } + + if (resolve && !node.isOperation) { + topOverriddenField?.takeIf { !it.resolve }?.also { + warnings.addOverriddenWarning(KobbyDirective.RESOLVE, it) + } + } + } + + private fun findTopOverriddenField(startNode: KobbyNode): KobbyField? = + overriddenField?.takeIf { it.node != startNode }?.let { + it.findTopOverriddenField(startNode) ?: it + } + + private fun MutableList.addPropertyWarning(directive: String) { + if (arguments.isNotEmpty()) { + this += "Restriction violated [${node.name}.$name]: " + + "The [@$directive] directive can only be applied to a field with no arguments." + } + + if (type.node.kind != SCALAR && type.node.kind != ENUM) { + this += "Restriction violated [${node.name}.$name]: " + + "The [@$directive] directive can only be applied to a field that returns a scalar or enum type." + } + } + + private fun MutableList.addOverriddenWarning(directive: String, topField: KobbyField) { + this += "Restriction violated [${node.name}.$name]: " + + "The [@$directive] directive cannot be applied to overridden fields. " + + "Please, apply [@$directive] directive to [${topField.node.name}.${topField.name}] field." + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/kobby-model/src/main/kotlin/io/github/ermadmi78/kobby/model/KobbySchema.kt b/kobby-model/src/main/kotlin/io/github/ermadmi78/kobby/model/KobbySchema.kt index 83ef3f71..089797a2 100644 --- a/kobby-model/src/main/kotlin/io/github/ermadmi78/kobby/model/KobbySchema.kt +++ b/kobby-model/src/main/kotlin/io/github/ermadmi78/kobby/model/KobbySchema.kt @@ -36,6 +36,24 @@ class KobbySchema internal constructor( fun unions(action: (KobbyNode) -> Unit) = unions.values.forEach(action) fun enums(action: (KobbyNode) -> Unit) = enums.values.forEach(action) fun inputs(action: (KobbyNode) -> Unit) = inputs.values.forEach(action) + + fun validate(): List { + val warnings = mutableListOf() + + interfaces { node -> + node.fields { field -> + field.validate(warnings) + } + } + + objects { node -> + node.fields { field -> + field.validate(warnings) + } + } + + return warnings + } } fun KobbySchema(block: KobbySchemaScope.() -> Unit): KobbySchema = diff --git a/kobby-model/src/test/kotlin/io/github/ermadmi78/kobby/model/DirectiveValidationTest.kt b/kobby-model/src/test/kotlin/io/github/ermadmi78/kobby/model/DirectiveValidationTest.kt new file mode 100644 index 00000000..bca295a3 --- /dev/null +++ b/kobby-model/src/test/kotlin/io/github/ermadmi78/kobby/model/DirectiveValidationTest.kt @@ -0,0 +1,70 @@ +package io.github.ermadmi78.kobby.model + +import org.junit.jupiter.api.Test +import java.io.InputStreamReader +import kotlin.test.assertEquals + +/** + * Created on 30.08.2021 + * + * @author Dmitry Ermakov (ermadmi78@gmail.com) + */ +class DirectiveValidationTest { + @Test + fun testDirectiveRestrictions() { + "default_arguments_and_return_type".shouldViolate( + "Restriction violated [Query.first]: The [@primaryKey] directive can only be applied to a field with no arguments.", + "Restriction violated [Query.first]: The [@primaryKey] directive can only be applied to a field that returns a scalar or enum type.", + "Restriction violated [Query.second]: The [@required] directive can only be applied to a field with no arguments.", + "Restriction violated [Query.second]: The [@required] directive can only be applied to a field that returns a scalar or enum type.", + "Restriction violated [Query.third]: The [@default] directive can only be applied to a field with no arguments.", + "Restriction violated [Query.third]: The [@default] directive can only be applied to a field that returns a scalar or enum type." + ) + + "default_cannot_override".shouldViolate( + "Restriction violated [Country.id]: The [@primaryKey] directive cannot be applied to overridden fields. Please, apply [@primaryKey] directive to [IBase.id] field.", + "Restriction violated [Country.name]: The [@required] directive cannot be applied to overridden fields. Please, apply [@required] directive to [IBase.name] field.", + "Restriction violated [Country.description]: The [@default] directive cannot be applied to overridden fields. Please, apply [@default] directive to [IBase.description] field." + ) + + "default_can_override".shouldViolate() + "default_override".shouldViolate() + "default_enum".shouldViolate() + + "default_mix".shouldViolate( + "Restriction violated [Query.first]: The field is marked with several directives at once - @default, @required, @primaryKey, the behavior of the Kobby Plugin is undefined!", + "Restriction violated [Query.second]: The field is marked with several directives at once - @default, @required, @primaryKey, the behavior of the Kobby Plugin is undefined!", + "Restriction violated [Query.third]: The field is marked with several directives at once - @default, @required, @primaryKey, the behavior of the Kobby Plugin is undefined!", + "Restriction violated [Query.fourth]: The field is marked with several directives at once - @default, @required, @primaryKey, the behavior of the Kobby Plugin is undefined!" + ) + + "selection_no_optional".shouldViolate( + "Restriction violated [Query.first]: The @selection directive can only be applied to a field that contains optional arguments - nullable arguments or arguments with default value.", + "Restriction violated [Query.second]: The @selection directive can only be applied to a field that contains optional arguments - nullable arguments or arguments with default value.", + "Restriction violated [Query.fourth]: The @selection directive can only be applied to a field that contains optional arguments - nullable arguments or arguments with default value." + ) + + "selection_optional".shouldViolate() + + "selection_cannot_override".shouldViolate( + "Restriction violated [Country.base]: The [@selection] directive cannot be applied to overridden fields. Please, apply [@selection] directive to [Base.base] field." + ) + "selection_can_override".shouldViolate() + "selection_override".shouldViolate() + + "resolve_cannot_override".shouldViolate( + "Restriction violated [Country.base]: The [@resolve] directive cannot be applied to overridden fields. Please, apply [@resolve] directive to [Base.base] field." + ) + "resolve_can_override".shouldViolate() + "resolve_override".shouldViolate() + } + + private fun String.shouldViolate(vararg warnings: String) { + val schema = parseSchema( + emptyMap(), + InputStreamReader(this@DirectiveValidationTest.javaClass.getResourceAsStream("$this.graphqls.txt")!!) + ) + + assertEquals(listOf(*warnings), schema.validate()) + } +} \ No newline at end of file diff --git a/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_arguments_and_return_type.graphqls.txt b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_arguments_and_return_type.graphqls.txt new file mode 100644 index 00000000..3e7462ab --- /dev/null +++ b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_arguments_and_return_type.graphqls.txt @@ -0,0 +1,14 @@ +directive @primaryKey on FIELD_DEFINITION +directive @required on FIELD_DEFINITION +directive @default on FIELD_DEFINITION + +type Query { + first(arg: Int): [Country!]! @primaryKey + second(arg: Boolean! = false): Country! @required + third(arg: String!): Country @default +} + +type Country { + id: ID! + name: String! +} \ No newline at end of file diff --git a/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_can_override.graphqls.txt b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_can_override.graphqls.txt new file mode 100644 index 00000000..d6e8a386 --- /dev/null +++ b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_can_override.graphqls.txt @@ -0,0 +1,25 @@ +directive @primaryKey on FIELD_DEFINITION +directive @required on FIELD_DEFINITION +directive @default on FIELD_DEFINITION + +type Query { + countries: [Country!]! +} + +interface IBase { + id: ID! @primaryKey + name: String! @required + description: String @default +} + +interface ICountry implements IBase { + id: ID! + name: String! + description: String +} + +type Country implements ICountry & IBase { + id: ID! @primaryKey + name: String! @required + description: String @default +} \ No newline at end of file diff --git a/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_cannot_override.graphqls.txt b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_cannot_override.graphqls.txt new file mode 100644 index 00000000..2ca4ccd3 --- /dev/null +++ b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_cannot_override.graphqls.txt @@ -0,0 +1,25 @@ +directive @primaryKey on FIELD_DEFINITION +directive @required on FIELD_DEFINITION +directive @default on FIELD_DEFINITION + +type Query { + countries: [Country!]! +} + +interface IBase { + id: ID! + name: String! + description: String +} + +interface ICountry implements IBase { + id: ID! + name: String! + description: String +} + +type Country implements ICountry & IBase { + id: ID! @primaryKey + name: String! @required + description: String @default +} \ No newline at end of file diff --git a/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_enum.graphqls.txt b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_enum.graphqls.txt new file mode 100644 index 00000000..619b4a47 --- /dev/null +++ b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_enum.graphqls.txt @@ -0,0 +1,15 @@ +directive @primaryKey on FIELD_DEFINITION +directive @required on FIELD_DEFINITION +directive @default on FIELD_DEFINITION + +type Query { + first: [MyEnum!]! @primaryKey + second: MyEnum! @required + third: MyEnum @default +} + +enum MyEnum { + FIRST, + SECOND, + THIRD +} \ No newline at end of file diff --git a/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_mix.graphqls.txt b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_mix.graphqls.txt new file mode 100644 index 00000000..1c68c5e0 --- /dev/null +++ b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_mix.graphqls.txt @@ -0,0 +1,16 @@ +directive @primaryKey on FIELD_DEFINITION +directive @required on FIELD_DEFINITION +directive @default on FIELD_DEFINITION + +type Query { + first: Int! @primaryKey @required + second: String! @primaryKey @default + third: Boolean @required @default + fourth: MyEnum! @primaryKey @required @default +} + +enum MyEnum { + FIRST, + SECOND, + THIRD +} \ No newline at end of file diff --git a/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_override.graphqls.txt b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_override.graphqls.txt new file mode 100644 index 00000000..39b6dd86 --- /dev/null +++ b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/default_override.graphqls.txt @@ -0,0 +1,25 @@ +directive @primaryKey on FIELD_DEFINITION +directive @required on FIELD_DEFINITION +directive @default on FIELD_DEFINITION + +type Query { + countries: [Country!]! +} + +interface IBase { + id: ID! @primaryKey + name: String! @required + description: String @default +} + +interface ICountry implements IBase { + id: ID! + name: String! + description: String +} + +type Country implements ICountry & IBase { + id: ID! + name: String! + description: String +} \ No newline at end of file diff --git a/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/resolve_can_override.graphqls.txt b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/resolve_can_override.graphqls.txt new file mode 100644 index 00000000..cc93662e --- /dev/null +++ b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/resolve_can_override.graphqls.txt @@ -0,0 +1,14 @@ +directive @resolve on FIELD_DEFINITION + +type Query { + countries: [Country!]! +} + +interface Base { + base: String @resolve +} + +type Country implements Base{ + id: ID! @resolve + base: String @resolve +} \ No newline at end of file diff --git a/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/resolve_cannot_override.graphqls.txt b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/resolve_cannot_override.graphqls.txt new file mode 100644 index 00000000..097c9a2a --- /dev/null +++ b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/resolve_cannot_override.graphqls.txt @@ -0,0 +1,14 @@ +directive @resolve on FIELD_DEFINITION + +type Query { + countries: [Country!]! +} + +interface Base { + base: String +} + +type Country implements Base{ + id: ID! @resolve + base: String @resolve +} \ No newline at end of file diff --git a/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/resolve_override.graphqls.txt b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/resolve_override.graphqls.txt new file mode 100644 index 00000000..6901ef0d --- /dev/null +++ b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/resolve_override.graphqls.txt @@ -0,0 +1,14 @@ +directive @resolve on FIELD_DEFINITION + +type Query { + countries: [Country!]! +} + +interface Base { + base: String @resolve +} + +type Country implements Base{ + id: ID! @resolve + base: String +} \ No newline at end of file diff --git a/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/selection_can_override.graphqls.txt b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/selection_can_override.graphqls.txt new file mode 100644 index 00000000..6fa88990 --- /dev/null +++ b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/selection_can_override.graphqls.txt @@ -0,0 +1,14 @@ +directive @selection on FIELD_DEFINITION + +type Query { + countries: [Country!]! +} + +interface Base { + base(arg0: Int!, arg1: String! = "test"): String @selection +} + +type Country implements Base{ + id: ID! + base(arg0: Int!, arg1: String! = "test"): String @selection +} \ No newline at end of file diff --git a/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/selection_cannot_override.graphqls.txt b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/selection_cannot_override.graphqls.txt new file mode 100644 index 00000000..00022f10 --- /dev/null +++ b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/selection_cannot_override.graphqls.txt @@ -0,0 +1,14 @@ +directive @selection on FIELD_DEFINITION + +type Query { + countries: [Country!]! +} + +interface Base { + base(arg0: Int!, arg1: String! = "test"): String +} + +type Country implements Base{ + id: ID! + base(arg0: Int!, arg1: String! = "test"): String @selection +} \ No newline at end of file diff --git a/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/selection_no_optional.graphqls.txt b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/selection_no_optional.graphqls.txt new file mode 100644 index 00000000..93e847ae --- /dev/null +++ b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/selection_no_optional.graphqls.txt @@ -0,0 +1,11 @@ +directive @selection on FIELD_DEFINITION + +type Query { + first: Int! @selection + second(arg0: Int!, arg1: String!): String! @selection + fourth(arg0: Int!, arg1: String!): Country! @selection +} + +type Country { + id: ID! +} \ No newline at end of file diff --git a/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/selection_optional.graphqls.txt b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/selection_optional.graphqls.txt new file mode 100644 index 00000000..462d1ca1 --- /dev/null +++ b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/selection_optional.graphqls.txt @@ -0,0 +1,11 @@ +directive @selection on FIELD_DEFINITION + +type Query { + first(arg0: ID): Int! @selection + second(arg0: Int!, arg1: String): String! @selection + fourth(arg0: Int!, arg1: String! = "test"): Country! @selection +} + +type Country { + id: ID! +} \ No newline at end of file diff --git a/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/selection_override.graphqls.txt b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/selection_override.graphqls.txt new file mode 100644 index 00000000..c26e408e --- /dev/null +++ b/kobby-model/src/test/resources/io/github/ermadmi78/kobby/model/selection_override.graphqls.txt @@ -0,0 +1,14 @@ +directive @selection on FIELD_DEFINITION + +type Query { + countries: [Country!]! +} + +interface Base { + base(arg0: Int!, arg1: String! = "test"): String @selection +} + +type Country implements Base{ + id: ID! + base(arg0: Int!, arg1: String! = "test"): String +} \ No newline at end of file