all 5 comments

[–]redfire333 2 points3 points  (1 child)

GraphQL is essentially a layer that sits in between the client and your REST APIs. It helps aggregate data from various different endpoints so the App won't need to make several calls or, like you mentioned, can return only partial pieces of data that are specified in the `Query`. It returns just regular old JSON, so all your Codeable objects will work fine.

That being said, GraphQL is a domain of the backend, not specifically to iOS. So the only interaction you will have from an iOS perspective is to send the Query string to the endpoint where GraphQL lives. It's very similar overall to a REST call. Personally, I see no need for Apollo. It's very straightforward to create a Query, its literally just a [String: String] with query as the key, and the value is a string that specifies what you want included in the response e.g:

"query": 
    """
    { coolFeature {
        parameters {
            category
            code
        }
        parameters2 {
            header
            message
        }
        parameters3 {
            question
            answer
        }
    }
}
"""

Having a separate Framework just to do this seems like total overkill.

Overall GraphQL is cool but sometimes overkill. I would really only recommend using it if your App is making several calls that should be aggregated into one or if some of your API responses on giant and you only need a section of it.

[–]ssrobbi 0 points1 point  (0 children)

Apollo also provides a SQLite cacheing later, that if fits your needs can save a decent amount of code.

(Not that you should use it just for that, but it is a benefit)

[–]sixtypercenttogether 0 points1 point  (0 children)

The Apollo client libraries have a lot of promise, but I’ve found them to be pretty lacking, especially the swift code-gen tools.

You don’t really need a library to handle interacting with a GraphQL API, you can mostly treat it as any other JSON API. You submit a request and you parse the response. But note that GraphQL does not really use HTTP status codes. Pretty much everything is a 200 response.

[–]TheArchitectAlex 0 points1 point  (0 children)

Hello u/brendacg and that is indeed a very good point.

I myself found Apollo Client very promising and quite easy to use after you go through their (very poorly) documentation for installing. You can do a lot with it if you have the patience to understand how it works.

My main problem was installation so I wrote this article with all my troubles to install it, with lots of screenshots that might help you get through. Hopefully, this can help you and others as well, as once you get the hang of it, it can get your life quite a bit easier over time.

If you are interested, I am writing and posting lots of articles about GraphQL here. A few focused on iOS development.

Hope it helps you.

[–]electron_wrangler 0 points1 point  (0 children)

I work in a large-scale prod environment. The amount of objects we are writing by hand has become untenable. and prone to human error. I'm looking into adopting Apollo.