question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mutation using Relationship field allow use of more fields in { connect { id } }

See original GitHub issue

Feature request

I takes multiple query to connect an existing item to Relationship item. First you have to query the item then send another query where you have to connect to this relationship item.

sometime you already have data which is not an ID, for example when you have forgotten password token, user coming to this url will have token but not id (assume id is different than token), then you have to call to get the id and then connect this to another item (assume we save token into a archived token list). this case you want to just use

mutation { createArchivedToken(data: { token: {connect: { token: $token } } }) {...fields} }

Describe the solution you’d like

I would like to use more field instead of just connect inside mutation. another example using a slug for post

mutation { updateUser(id: "some-id", data: {lastPost: {disconnectAll: true, connect: {slug: "post-slug }}}){id name lastPost { id author { id name }  } } } 

Describe alternatives you’ve considered

N/A

Additional context

this can enable more nested queries in future. Useful in case when you have some data already as part of other field but that is not a relationship field.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gautamsicommented, May 17, 2020

I agree that we should restrict use of nested query to WhereUnique to keep it simple. there is also use case when you have Relationship set to many: true then this should also allow non unique connectioins.

1reaction
jesstelfordcommented, May 16, 2020

With the current structure of nested operations, we would have to limit it to WhereUnique fields I think, otherwise it could potentially return more than one item.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQL schema basics
This schema defines a hierarchy of types with fields that are populated from your back-end data stores. The schema also specifies exactly which...
Read more >
GraphQL relationships - Fauna Documentation
The Fauna GraphQL API recognizes relationships based on the fields in the imported GraphQL schema. The relationship recognition algorithm looks at every ...
Read more >
GraphQL Tutorial: how to use fields, fragments, and more
First, we declare that createUser will be a mutation and accept arguments named email and password . Then in line 2, we declare...
Read more >
Mutations and Input Types
But in many cases, you will find a number of different mutations that all accept the same input parameters. A common example is...
Read more >
Solved: Add relational fields to create mutations?
I have a few object types in my schema with relationships. ... good What I'd like to do now is pass in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found