Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve support for isRequired on Relationships #719

Closed
timleslie opened this issue Feb 14, 2019 · 6 comments
Closed

Improve support for isRequired on Relationships #719

timleslie opened this issue Feb 14, 2019 · 6 comments

Comments

@timleslie
Copy link
Contributor

Due to the use of back-references, the isRequired flag is tricky to enforce for Relationship fields. At the moment I don't believe it's adequately implemented. This tasks needs someone to go through the Relationship field and ensure that the isRequired semantics are correctly implemented across all use cases.

@timleslie
Copy link
Contributor Author

Also, we absolutely need some comprehensive testing around this (and uniqueness) in the same way we do for filter tests.

@stale
Copy link

stale bot commented Feb 18, 2020

It looks like there hasn't been any activity here in over 6 months. Sorry about that! We've flagged this issue for special attention. It wil be manually reviewed by maintainers, not automatically closed. If you have any additional information please leave us a comment. It really helps! Thank you for you contribution. :)

@stale stale bot added the needs-review label Feb 18, 2020
@jesstelford
Copy link
Contributor

jesstelford commented Mar 14, 2020

Just got stung by this:

keystone.createList('User', {
  fields: {
    name: { type: Text },
  },
});

keystone.createList('Post', {
  fields: {
    author: {
      type: Relationship,
      ref: 'User',
      isRequired: true,
    }
  }
});

The isRequired check appears to do nothing:

mutation createPost {
  createPost(data:{}) {
    id
    author {
      id
    }
  }
}

Successfully creates a new item.


I think the most basic implementation should at least:

  1. Set the field as required in the graphQL schema. (currently it's just input PostCreateInput { author: UserRelateToOneInput }) Whoops, no, we can't do this because of our defaultValue() functions
  2. Check for at least one of the possible operations (create / connect / disconnect / disconnectAll) having any value.

@MadeByMike
Copy link
Contributor

We should update the docs until this is resolved.

@bladey bladey closed this as completed Apr 8, 2021
@christopherliu
Copy link

Hello! It looks like isRequired is not supported on relationships in Keystone v6 as well as v5. Is this the proper channel to hear updates on this, given that the issue is closed, or should I open a new feature request issue?

@dcousens
Copy link
Member

dcousens commented Mar 14, 2022

Hi @christopherliu,

There is an open discussion around this at #7310.
We'll try and answer with our reasoning for why isRequired is missing soon!

@keystonejs keystonejs locked as resolved and limited conversation to collaborators Mar 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants