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

Add @key as primary key fields instead of nodeId #1

Open
jgzuke opened this issue Jun 30, 2019 · 5 comments
Open

Add @key as primary key fields instead of nodeId #1

jgzuke opened this issue Jun 30, 2019 · 5 comments

Comments

@jgzuke
Copy link

jgzuke commented Jun 30, 2019

When using Graphile federated with another service, it seems to make more sense for the key to be on the primary keys of the resource instead of the nodeId. This is because any other resource would be likely to have access to the resource by its primary keys.

This can be worked around by adding @requires(fields: {primary keys}) to each other field and fetching by the keys in __resolveReference but this seemed like a bad solution.

@benjie
Copy link
Member

benjie commented Jun 30, 2019

This plugin is datasource-independent currently, there’s nothing PostgreSQL specific in it. This means it works with any Graphile Schema, not just PostGraphile, which is pretty cool I think.

That said, I’d like to allow other ways of specifying @key on various things, and your request is reasonable. Would be cool to add different federation strategies.

@benjie
Copy link
Member

benjie commented Jun 30, 2019

Sorry @key; I’ll try and remember to use backticks in future!

@jgzuke
Copy link
Author

jgzuke commented Jun 30, 2019

Hmm, im not sure what you mean by being able to work with any Graphile schema. If we used primaryKeyConstraint fields (if there are any), that seems like it would still work with any schema. I think im missing some detail.

@jgzuke
Copy link
Author

jgzuke commented Jun 30, 2019

I made #2 as an example of what ive been using locally in case my description before was unclear or not specific enough.

@benjie
Copy link
Member

benjie commented Jul 1, 2019

Graphile Engine is data-source independent. You can make GraphQL schemas with Graphile Engine that have nothing to do with PostgreSQL. PostGraphile then adds a bunch of plugins (graphile-build-pg) to build an automatic GraphQL API over PostgreSQL.

I’ll take a look at your PR 👍

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