Comments (6)
Could the JSON deserialization be optional? It's safe to ship with, but it would be nice to have some sort of plug allowing someone to continue using their own deserialization method.
from apollo-ios.
The issue with this is that strictly taken the type system is defined by GraphQL, and JSON is just one serialization format. What that means in practice is that there are GraphQL-specific features that existing JSON mappers don't necessarily support well.
For instance, a GraphQL enum value would be serialized as a JSON string, but as a client you expect an actual enum of the right type to be returned. There are also issues around the handling of optional values. And things quickly get more complicated when you take more advanced GraphQL features into account, like polymorphic results, where a __typename
field decides what the actual type returned is.
If you're interested, you'll find some more details of the proposed mappings in the design docs.
There are probably things that could be be improved about the current implementation of JSON parsing and the resulting mapping, but I feel having this be part of the project offers us more flexibility and is worth the overhead. If we find a good use case for pluggable serialization formats, we can take it from there.
from apollo-ios.
Would it make sense to remove JSON Parsing at all to concentrate on GraphQL.
Doesn't GraphQL return results in JSON? What would a GraphQL client without JSON parsing do?
from apollo-ios.
It does. But what if your implementation returns as Dictionary<String, Any> as result. The Consumer of the can then decide how to parse it. If I find time tomorrow I will add a little example here
from apollo-ios.
You only would definde some kind of JSON protocol and the consumer of your API has to implement it.
This library could concentate on a great GraphQL implementation and not try to solve JSONMapping
protocol JSONInitializable {
init(map: Dictionary<String, Any>) throws
}
public protocol GraphQLQuery {
var operationDefinition: String { get }
var queryDocument: String { get }
var variables: GraphQLMap? { get }
associatedtype Data: JSONInitializable
}
from apollo-ios.
I like the idea from @Mattfxyz. But this would not remove the overhead of implementing a JSON mapper.
from apollo-ios.
Related Issues (20)
- Is Swift 5.9 required for Apollo 1.8.0? HOT 3
- There can be only one directive named "@defer".-GraphQLSchemaValidationError@ HOT 6
- Feature: Time based expiring cache HOT 1
- ci: Update SimpleUploadServer
- Enable Decoding Responses Omitting Null Values (Set HandleMissingValues to .allowForOptionalFields in GraphQLSelectionSetMapper) HOT 2
- VisionOS Support HOT 10
- Duplicate entries in `__mergedSources` HOT 5
- Codegen Option: Optional Exported Imports HOT 8
- apollo-ios-codegen 1.8.0 CustomScalar is 'should not be edited.' HOT 2
- Variables Inside Fragments behaving oddly? HOT 14
- Invalid HTTP upgrade spams the log instead of returning an error HOT 10
- `asXXXXXXX` property on a union never returning `nil` if selection set empty HOT 4
- Cache mutations are somewhat painful to work with HOT 5
- Add PrivacyManifest HOT 1
- Can't Use 2 Different Schemas in same Package HOT 2
- `SelectionSet` Generated Initializers Don't Compile with `self` Parameter HOT 5
- When using apollo-ios-pagination, there is an issue where data is not accurately updated when mutations occur. HOT 1
- Xcode Install CLI fails for versions >=1.8 HOT 11
- Test Issue HOT 1
- Testing author_association
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apollo-ios.