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

One-to-many relationships only connects two-ways for 2/~50 items. #2329

Closed
nathsimpson opened this issue Feb 3, 2020 · 2 comments
Closed

Comments

@nathsimpson
Copy link
Contributor

Bug report

Describe the bug

I’m having an odd problem with two-way relationships.
Scenario, I have two lists (session and competitor ). A competitor relates to one session and a session has many competitors.
When I run my createCompetitors mutation, it ‘connects’ the 50 new competitors to an existing session successfully, but if I query for session.competitior, I only get two records.
There is a lot of code, so I don’t know what makes sense to share here, but happy to answer any questions or show anyone tomorrow. (edited)

To Reproduce

Steps to reproduce the behaviour. Please provide code snippets or a repository:

  1. Create a keystone app with the following schema
exports.Session = {
  schemaDoc: "A session during a race weekend",
  fields: {
    name: { type: Text, schemaDoc: "Name of session" },
    competitors: { type: Relationship, ref: "Competitor.session", many: true },
  }
};

exports.Competitor = {
  schemaDoc: "A car/driver that took part in a session",
  fields: {
    name: { type: Text, schemaDoc: "Driver(s) name" },
    session: { type: Relationship, ref: "Session.competitors" },
  }
};
  1. Create a session and capture the ID
  2. Run a createCompetitors mutation...
data = [
  {
    data: {
      name: "A",
      session: { connect: { id: sessionId } }
    }
  },
  {
    data: {
      name: "B",
      session: { connect: { id: sessionId } }
    }
  },
  {
    data: {
      name: "C",
      session: { connect: { id: sessionId } }
    }
  },
..... plus 47 items
];
mutation createCompetitors($data: [CompetitorsCreateInput]) {
  createCompetitors(data: $data) {
    id
  }
}
  1. Run an 'allCompetitors' query, all of them should have a valid 'session'
  2. Run an allSessions query, the session should only have two competitors.

Expected behaviour

The session should have all 50 competitors related to it

@nathsimpson
Copy link
Contributor Author

Workaround for anyone who finds this issue may be to run 50 createCompetitor (singular) mutations.

@timleslie
Copy link
Contributor

Fixed by #2000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants