graphql-constraint-directive icon indicating copy to clipboard operation
graphql-constraint-directive copied to clipboard

Using "uniqueTypeName: Int" behalves unexpected

Open simlu opened this issue 3 years ago • 2 comments

When using limit: Int @constraint(uniqueTypeName: "Int", min: 1, max: 200), I would expect the validation to still run. However no errors are generated.

Is this expected behavior? Is this something this library should support?

I get that conceptually there could be two types of "Int" (one with a constraint and one without) - which goes a little against the graphql schema logic. Consider throwing an assert maybe?

I'm honestly not sure what the correct path of action is here

simlu avatar May 30 '22 18:05 simlu

Yes, this is expected. The validation won't run in this case; as the name suggests it needs to be a unique name. Under the hood, this module auto generates a unique type for anything decorated with the directive.

The correct action would be to throw an error if it's a type name which already exists

confuser avatar Jun 03 '22 11:06 confuser

@confuser OK thank you for the reply! Should this issue be labeled improvement then?

simlu avatar Jun 03 '22 12:06 simlu