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

Make parseResult public again #46

Merged
merged 1 commit into from
Feb 6, 2017
Merged

Make parseResult public again #46

merged 1 commit into from
Feb 6, 2017

Conversation

fwal
Copy link
Contributor

@fwal fwal commented Feb 1, 2017

We currently use Apollo as de-/serialiser for our graphql requests within our pre-existing network stack and it works really well.

We used this method for achieving this but it was recently made internal.

@apollo-cla
Copy link

@fwal: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@martijnwalraven
Copy link
Contributor

I'd like to better understand your use case. Which part of your app calls parseResult? To integrate with a pre-existing network stack, wouldn't it be enough to implement your own NetworkTransport?

Maybe you could also chime in on #6?

@MrAlek MrAlek mentioned this pull request Feb 2, 2017
@martijnwalraven
Copy link
Contributor

I'm a little hesitant to make parseResult public because its current implementation includes result normalization, and if you only want to deserialize a result, that is wasted effort that could be avoided by implementing result parsing yourself (which should only take a few lines of code).

What do you think?

@MrAlek
Copy link
Contributor

MrAlek commented Feb 6, 2017

@martijnwalraven Parsing the result ourselves would require implicit knowledge of implementation details (such as that the main body is under the data key).

Also, responseName on Field is internal right now so it can't be done without modification anyway. The cleanest API would be to keep parseResult public.

if let dataEntry = body["data"] as? JSONObject {
    let reader = GraphQLResultReader(variables: operation.variables) { field, object, info in
        return (object ?? dataEntry)[field.responseName]
    }
    data = try Operation.Data(reader: reader)
}

@martijnwalraven
Copy link
Contributor

@MrAlek: Let's make it public for now then, with the understanding that the API may change again in the future. I also still think it's valuable to continue the conversation in #6 to see if there isn't a better way to do this.

@martijnwalraven martijnwalraven merged commit 8fbd25f into apollographql:master Feb 6, 2017
@MrAlek
Copy link
Contributor

MrAlek commented Feb 6, 2017

@martijnwalraven Thanks! And yes, of course, I'm working on a second integration from our end currently (using ApolloClient) and will get back to you with some thoughts based on that.

@martijnwalraven
Copy link
Contributor

Great! I'm also in the process of writing some API documentation, so that may also help.

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

Successfully merging this pull request may close these issues.

4 participants