-
Notifications
You must be signed in to change notification settings - Fork 712
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
Public access to jsonObject on GraphQLMap #18
Comments
We talked a little about this at the Berlin meetup. As I mentioned there, I'm working on a new version that fixes some issues with I want to make sure the new design works for your use case as well. Can you tell me more about what you're trying to do? What networking library are you using, how do you integrate with it, and why do you need to use it instead of the default network transport? |
I just released version 0.4.0 of Apollo iOS, which includes a redesigned Please give it a try and let me know what you think! (You'll also have to update apollo-codegen to 0.9, but it will warn you if you don't.) |
Hey Martijn! Thanks for your work! |
Good to hear! I agree Maya doesn't add much value here and seems more confusing than helpful. I'd be interested in hearing more about how you approach testing, to better understand the requirements and to see if there's anything more we could add to make it easier. Stubbing the network transport is probably the best solution right now, especially if you'd like to test for error conditions. I think you're right and you don't you need to test for bad JSON. The only bad JSON I can think of would be an invalid GraphQL response, probably as a result of a bug in the server library. So you're left with either a network or GraphQL errors to test for. I'm wondering how adding caching and consistency management (which I'm working on right now) will affect testing. Depending on what you're testing, it may make sense to preload the store with test data for example, instead of stubbing the network transport. |
Hey Martijn, I've now tried and failed to stub a fake NetworkTransport for a query. I tried:
but I don't really know what to put in there. For me it would be awesome if I could directly stub the a json response string like this:
To make that work you could somehow inject an encoded json response ( Also, I changed the access level of the HTTPNetworkTransport class, to make it easy to subclass and debug, why a request might have gone wrong (easier logging): here |
You should be able to just construct a let response = GraphQLResponse(operation: query, rootObject: [
"data": [
"hero": ["__typename": "Droid", "name": "R2-D2"]
]
]) (See ParseQueryResponseTests.swift for more examples.) If you really want to pass in a JSON string instead, you could create a helper method that uses func jsonObject(string: String) -> JSONObject {
let data = string.data(using: .utf8)!
return (try! JSONSerialization.jsonObject(with: data, options: [])) as! JSONObject
} |
I will try that, thanks :) |
Hey.
Could you provide public access to the
GraphQLMap
'sjsonObject
property? I try to use apollo-ios with another networking library, so I'll need to have the parameters unencoded.For this I extract the information from the query/mutation:
The
dict
is a computed property onGraphQLMap
which parses thedescription
back to a dictionary (hacky). This is just unnecessary overhead, because I could use thejsonObject
directly. Since it's private clients can't change it anyway :)The text was updated successfully, but these errors were encountered: