https://kotlinlang.org logo
#graphql-kotlin
Title
# graphql-kotlin
j

jmfayard

01/25/2022, 10:56 AM
Hello, is there an equivalent or a way to implement the
@constraint
directive from ApolloGraphQL? https://www.apollographql.com/blog/backend/validation/graphql-validation-using-directives/
Copy code
type SignUpInput {
  email: String! @constraint(format: "email", maxLength: 255)
  password: String! @constraint(maxLength: 255)
}
d

Dariusz Kuc

01/25/2022, 1:17 PM
j

jmfayard

01/25/2022, 2:55 PM
Thank you. Following the official samples, I created an annotated
ConstraintDirective
and its
ConstraintDirectiveWiring
which I registered in a `KotlinDirectiveWiringFactory`which itself is registered as hooks inside a
SchemaGeneratorConfig
But still the directive does not appear in the generated GraphQL Schema. I'm using ktor. Is there maybe some magic that works only with Spring Boot?
d

Dariusz Kuc

01/25/2022, 3:01 PM
Sounds like it should work, can you share a repo?
👀 1
s

Shane Myrick

01/25/2022, 11:12 PM
Just to clarify, the
@constraint
directive you are referring to is a schema or server side directive and is logic that is applied to the field on every client operation with out them specifying anything. The HTTP framework should not matter. Also it is not from Apollo, it is from the GitHub user
confuser
https://github.com/confuser/graphql-constraint-directive
j

jmfayard

01/26/2022, 9:53 AM
d

Dariusz Kuc

01/26/2022, 4:42 PM
👍 I'll take a look today
59 Views