how to create mutation with foreign key?
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
I want to create mutation with domain class talk ,how to write the document?
```
@GrailsCompileStatic
class Speaker {
String firstName
String lastName
String name
String email
String bio
static hasMany = [talks: Talk]
static graphql = true
static constraints = {
email nullable: true, email: true
bio nullable: true
}
static mapping = {
bio type: 'text'
name formula: 'concat(FIRST_NAME,\' \',LAST_NAME)'
talks sort: 'id'
}
}
@GrailsCompileStatic
class Talk {
Speaker speaker
String title
int duration
static graphql = true
static belongsTo = [speaker: Speaker]
}
```
if i use the code like this:
```
mutation {
talkCreate(talk: {
title: "about K8S"
duration: 120
speaker: {
id: 1
}
}) {
id
title
duration
speaker {
id
}
errors {
field
message
}
}
}
```
the speaker_id always set null, why?
Contributor guide
Research direction
Review the Talk and Speaker domain classes and the talkCreate mutation shown in the report. Reproduce the mutation and verify whether the relationship is persisted by checking speaker_id and the returned speaker.id; the issue is done when the foreign key is no longer null.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, groovy
- Domain
- api, backend, database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100