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

How to @override a field from another subgraph using original value from that subgraph #3147

Open
kindermax opened this issue Sep 18, 2024 · 3 comments

Comments

@kindermax
Copy link

kindermax commented Sep 18, 2024

My case is: I have two subgraphs

products with type Product

type Product @key("id") {
  id ID!
  name: String!
}

and translations where I am trying to override name field

type Product @key("id") {
  id ID! @external
  name: String! @requires("name") @override("products")
}

The problem is - I do not know how to tell Gateway/Router that I need a field name from products subgraph and then I will use it in translations subgraph to generate a new value based on original value.

For example: if name field from products subgraph is IPhone, I need to modify it for example like: IPhone (EN).

Is it possible to achieve what I am trying to do ?

@dariuszkuc
Copy link
Member

Hello 👋
You cannot do it with the same field. You could use extra inaccessible field though

// products
type Product @key("id") {
  id ID!
  privateName: String! @inaccessible // <- this will not be available in the public API
}

// translations
type Product @key("id") {
  id ID!
  privateName: String! @external @inaccessible
  name: String! @requires("privateName")
}

@kindermax
Copy link
Author

Ok, that's a solution, thank you. Is it any chance that in the future federation will allow it to be possible to achieve this as I described ?

@dariuszkuc
Copy link
Member

👋 As the old saying goes, never say never.... but it seems very unlikely that we will be changing the @override behavior anytime soon.

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