-
Notifications
You must be signed in to change notification settings - Fork 731
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
Sharing input/output types when they match #137
Comments
This is a good one - I know I've been wanting to do some stuff with CodeGen to get fragments annotated as protocols so you can pass those fragments regardless of the query - I'll have to do some digging to see what we can do in terms of potentially making the response types also conform to that. |
Has there been any progress on this? I find it very cumbersome that types that are the same (in terms of what data they contain) are different depending on what query they are a part of. I have fiddled with different solutions but none has really worked out in a good way. What I have tried: The real solution is for the CodeGen to handle this but I realize that it is a hard problem to solve. |
This is something we're still looking into for new codegen, but after a year and a half of digging these are the potential issues I see:
You're definitely correct that this is a hard problem to solve - honestly all the codegen stuff has been way, way harder than I expected which is why it's comically behind. But those are at least some things we'll be thinking about as we move it forward. |
I’m also having problems with very similar queries that return the same thing but they get different types. This happens for example when I apply different filters to essentialy the same query. Maybe I’m missing something here though? |
Are you talking about the different nested types that are generated per-query, or different If it's the former, you probably want to look into using fragments for the overlapping fields. If it's the latter, that's something altogether different. |
It was the former. Thank you! My code is so much more beautiful now! 😃 |
Hi 👋🏻 - after looking at this issue again in preparation for the upcoming 1.0 release we've decided not to take this request into 1.0. If this is important to you please let us know in this issue - thank you. |
Per our slack conversation https://apollographql.slack.com/archives/C24NKC5DY/p1504670856000092 this issue is to discuss better solutions for sharing input/output types when they match.
For example, we have a type
Answer
. In a response, we have an array of[Answer]
. In the input type, we also have an array of[Answer]
. In both cases,Anser
has the same fields. However, since one is an input type and the other is an output type, it's not possible to easily convert one to another without manually mapping the fields from one to another.Are there any other recommendations for handling cases like this? For us, this usually occurs when the output type is something we need to modify (like a form) and then send back to the server to save any changes.
The text was updated successfully, but these errors were encountered: