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

Allow creating related items within single create mutation #186

Closed
jesstelford opened this issue Aug 3, 2018 · 1 comment · Fixed by #207
Closed

Allow creating related items within single create mutation #186

jesstelford opened this issue Aug 3, 2018 · 1 comment · Fixed by #207

Comments

@jesstelford
Copy link
Contributor

jesstelford commented Aug 3, 2018

Example

keystone.addList('User', {
  fields: {
    posts: { type: Relationship, ref: 'Post', many: true },
    org: { type: Relationship, ref: 'Org' },
  }
});

keystone.addList('Org', {
  fields: {
    name: { type: Text },
  }
});

keystone.addList('Post', {
  fields: {
    title: { type: Text },
  }
});

Current Output (after #199 is merged)

type CreateUserInput {
  posts: [ID]
}

type Mutation {
  createUser(data: CreateUserInput): User
}

Suggested Output

type CreateUserInput {
  posts: [UpdateOrCreatePostInput]
}

# NOTE: different input type as defined in https://github.com/keystonejs/keystone-5/issues/182
input LinkOrCreatePostInput {
  id: ID # NOTE: Can't pass both id AND create
  create: CreatePostInput
}

type Mutation {
  createUser(data: CreateUserInput): User
}

See also keystonejs/keystone-5#182 & keystonejs/keystone-5#185

@jesstelford
Copy link
Contributor Author

The same applies to the updateX mutations.

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

Successfully merging a pull request may close this issue.

1 participant