apache / apache/grails-core

Nullable property-constraint ignored

Open
#14,514 0 comments 0 reactions 0 assignees View on GitHub
relates-to: grails-data-graphql
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

Hi!
I set up an example Grails Application project following [this guide](https://grails.github.io/gorm-graphql/2.0.0/guide/index.html), however when setting the `firstName` property as not nullable this constraint is not respected, GraphiQL displays it as a nullable field in the `SpeakerCreate` type.

```groovy
static constraints = {
firstName nullable: false
email nullable: true, email: true
bio nullable: true
}

static graphql = GraphQLMapping.build {
property('firstName',
[
order : 2,
description: 'Author first name'
nullable: false'
])
}
```
![image](https://user-images.githubusercontent.com/42621479/78719243-3f200e80-78e9-11ea-8439-30d0e006bbd4.png)

Only if I remove the entire property mapping is the nullable constraint respected, but this prevents me from mapping the property with a custom order and description.

```groovy
static constraints = {
firstName nullable: false
email nullable: true, email: true
bio nullable: true
}

static graphql = GraphQLMapping.build {
/*property('firstName',
[
order : 2,
description: 'Author first name'
nullable: false'
])*/
}
```
![image](https://user-images.githubusercontent.com/42621479/78720050-9d012600-78ea-11ea-8496-b57485691acb.png)

Thanks in advance

Contributor guide

Open the contributing guide

Research direction

Start with the linked GORM GraphQL guide and reproduce the example using the shown Groovy constraints and GraphQLMapping property mapping. Inspect how GraphiQL exposes the SpeakerCreate field when a custom order and description are present. Done means firstName remains non-nullable while retaining its custom mapping.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, groovy
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.