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

[schema] Ensure default by: id for link() resolver #13591

Merged

Conversation

stefanprobst
Copy link
Contributor

This is for #13028

Because addResolver directive is generic we don't have defaultValue for options. So better ensure we have default by: id arg for link resolver.

@stefanprobst stefanprobst requested a review from a team as a code owner April 24, 2019 11:27
@@ -93,7 +93,7 @@ const paginate = (results = [], { skip = 0, limit }) => {
}
}

const link = ({ by, from }) => async (source, args, context, info) => {
const link = ({ by = `id`, from }) => async (source, args, context, info) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can/need to generate a unique id (based on timestamp or something) to set as default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sidharthachatterjee This is about the default node field for foreign-key relations. So that it is possible to say something like this in SDL:

type Post implements Node {
  author: AuthorJson @addResolver(type: "link")
  # instead of:
  # author: AuthorJson @addResolver(type: "link", options: { by: "id" })
}

The ID itself must already be unique on nodes. Hope that make sense?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense! Thank you for the added context, @stefanprobst

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 this pull request may close these issues.

2 participants