Skip to content

[2022-08-04] Redefine the problem that "struct" is solving #1100

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

Closed
benjie opened this issue Aug 16, 2022 · 8 comments
Closed

[2022-08-04] Redefine the problem that "struct" is solving #1100

benjie opened this issue Aug 16, 2022 · 8 comments

Comments

@benjie
Copy link
Member

benjie commented Aug 16, 2022

Lee: Wrapping this up. Advice: Back up from proposal to redefine the problem. For input unions that was very helpful. A lot to like, but also opening up a lot of things we decided against. Sounds a bit like a panacea. We might solve all problems, but in an inadequate way.

🎥 Timestamped YouTube link


Note: Action Item issues are reviewed and closed during Working Group
meetings.

@benjie benjie self-assigned this Aug 16, 2022
@leebyron
Copy link
Collaborator

leebyron commented Sep 1, 2022

Related to the Metadata discussion on 9/1 - may expand on this in the future

@benjie
Copy link
Member Author

benjie commented Oct 21, 2022

Update from last night's WG: we still need to collect more use cases, but "structured leaves" is definitely a problem that needs solving one way or another.

@benjie
Copy link
Member Author

benjie commented Oct 11, 2023

As agreed at the October 2023 WG; action items that have been inactive for more than 6 months can be closed.

@benjie benjie closed this as completed Oct 11, 2023
@benjie
Copy link
Member Author

benjie commented Oct 11, 2023

I still feel that struct does a great job of solving the "structured symmetric data" problem (e.g. as a replacement for JSON scalar, because you can pull it down, modify it, and then send is straight up again without having to worry about the addition of new fields causing breakage). It also felt like a great solution for the other problems I laid out in the RFC... I might write a fresh RFC for it at some point that addresses just the "structured symmetric data" problem. I still think solving the various other issues has value though.

@benjie
Copy link
Member Author

benjie commented Nov 6, 2023

Another example of someone having a problem that fits well into what struct offers: graphql/graphql-spec#929 (comment)

@holomekc
Copy link

Hi @benjie ,
we also face the same issues. Our workaround is also a JSON scalar, so basically serialized json string in our response. We do not really like it and would love to see the struct rfc becoming a reality. I could find some discussions in different issues regarding this issue, but it seems that this one is the latest one where you wrote something. What is the current status of this feature?

@benjie
Copy link
Member Author

benjie commented Feb 1, 2025

Please share more details of your use case; the issue at the WG was that strict solved too many problems and may not have been the best solution for any of them, so we need to have some concrete full use cases that we can then find solutions for, which may include struct as an option. Maybe you could start by explaining how JSON scalar is insufficient for your needs?

@holomekc
Copy link

holomekc commented Feb 1, 2025

I cannot share company internal information, but I can map and simplify it to something else. I hope it helps:

type Thing {
  name: String!
}

type SpecialThing implement Thing {
  name: String!
  additionalValue: String!
}

type RecursionIssueThing implements Thing {
  name: String!
  things: [Thing]
}

type Agent {
  id: String!
  things: [Thing]
}

type AgentMetaData {
  id: String!
}

type Query {
  agents: [AgentMetaData]
  agent(id: String!): Agent
}

The issue is our RecursionIssueThing, because it uses the interface Thing again. When we try to query the data we cannot define a fragment, which creates a cycle.

Our Agent can have Things, which are defined by a different system. It is totally unclear how the Things are structured. We have 7 similar types to SpecialThing and 1 additional type similar to RecursionIssueThing. In this case our gui always requires all information. So a query like this sounds great, but is sadly currently not possible:

query {
  agent(id: "1") {
    id
    things
  }
}

Defining the complete structure is already for one level kind of difficult. So your struct concept sounded great, because we could handle Things like a leaf.

Instead, at the moment we defined a scalar Any, which serializes the information from above to a string. So we loose the type safetly. It is more like a hidden secret now, how the Things are structured.

Edit: We also generate the queries and response types, which typically remove the need to write the models by hand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants