SwiftConf '17: Nikolas Burk — GraphQL for iOS Developers

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
you is you you want exactly I submitted the talk here and you submitted the talk and so the the funny thing is also we kept on speaking English all the time even though both of us speak German for me it doesn't make any difference because none of those languages are is or is my mother tongue anyways and so yet I'm really keen on learning about graph QL because I've heard stuff about it but I I still have no actual clue about what it actually is good stuff so let's give a round of applause for Nicolas yeah thank you stuff thank you for the introduction all right can we switch the screen to my slides though that would be helpful all right graph QL for native high-res developers that's the title of the talk before we get into the actual talk so I really want to get a feeling for the audience here and for like who has already heard of graph QL and who has worked with graph gills so who has heard of graph QL raise your hand all right maybe it's easier to ask who has not heard of graph QL yet all right still a couple of people that's very nice okay who has used graph QL either with Swift or with any kind of other technology all right we actually have people who've used it who has used it with Swift one person with Swift okay so that's really good because that is really the main part of this talk I actually prepared like a large practical part where I'm going to show you and we're going to build a small application with graph QL and with Swift all right so Who am I my name is Nicholas Burke and I work at a company called Graff cool we are a start-up based in Berlin and we are basically building a back-end development platform for graph QL and serverless technologies so we we kind of have this idea of the backend as a service so if you're just a front-end or a mobile developer you can just use our service and have your completely product ready back-end with a couple of clicks and then I'm also a tutorial author at the Raven Dalek website which I assume all of you are familiar with let's take a look at what we want to cover today so first I want to give like a brief introduction to graph QL but this is really not a conceptual talk today it's a very very practical talk so I'll keep that part very very brief then I'm going to explain how you can use graph QL together with swift using the Apollo client and then we'll get into the demo so let's start with the gradual introduction and the big question what is graph QL so in short it's a new API standard that was developed and open-source by Facebook in 2015 so it's really only two years old but Facebook already started working on graph QL in 2012 and they actually have already been using graph QL since then in their native mobile apps so if you remember back at the time the Facebook the Facebook app actually was this weird aged Tim l5 app that had a lot of problems and when they decided to rewrite this application they were also using graph clear for that and despite the fact that it shares the same suffix with sequel so it's a query language but it does not really have anything to do with a database so it's not a database technology and that's a really key part to understand it's a Cree language for api's not for databases and it basically enables a declarative way of fetching and updating data a declarative way of working with api's so it provides a special syntax that allows a client application to describe some data requirements send that over to a server the server is going to resolve these data requirements and send that and send back the result to the client let's take a look at a simple example so let's assume we have a conference planner app with a table view that should display a number of conferences so in such a situation we will typically have like one rest endpoint that you hexxus something like slash conferences that would return a that would return an array of conference data and here the conference were here each conference has an ID a name a city and a year and then we got a whole bunch of conferences that we download into the application and that we can then render inside a table view um but maybe we also since it's a conference planner app we also have the concept of an attendee so an attendee can attend a conference so if we want to download all the attendees for a specific conference we would have to go and access like a rest endpoint that might look similar to this so slash conferences then the idea of the conference of which we want to download the attendees and then slash attendees and this might just return the attendees that have been registered for this particular conference all right so now we have this view and we can perfectly render it with the slash conferences endpoint because that gives us exactly the data that we need but what if our designers now say that the app would be a lot better if for each conference we could actually also display the last three people who registered for that conference so what are the options that we now have essentially the first option would be to adjust the API so here is what the data that the server is going to return look like before but if we wanted to custom it to actually customize it for this particular use case now we would have to go and tell our server engineers to make it something like this so that we include the information that we need on the screen in the in the payload that we receive from the server so this would be one way out of that situation but this really won't allow you to iterate quickly on your designs if you make changes frequently and you want to incorporate user feedback and you have to adjust the API every time that you need different data for a particular screen and then potentially you also have multiple apps who have these requirements and these situations you just have to work a lot on the backend side and this is not really a scalable approach that you want to have so the second option would be you just go with the way how the API is designed at the moment and you have to send n plus-1 requests the first request is to get all the conference's so that you get all the conference IDs and then you have to load the attendees for the first conference the second one third for eventful force and until you get all the attendees so that you can display them inside the application alright so this is also not really a desirable a desirable situation because we were making a lot of Network requests and downloading a lot of data even though that's not really all required inside the application so how would we solve this same situation with graph QL now so with graph QL we could essentially specify what's called a query and send this query over to the server and here is a really important point that you have to realize when you compare rest with graph QL so with rest we usually make use of these different HTTP methods that we have available in particular get post put and delete so if you have a REST API that makes use of these methods it's generally a well-designed REST API and with graph QL on the other hand we don't really care about the transport layer and we could actually like build a graphical API with another transport layer than HTTP but the most common implementations of graph QL are using HTTP and there it works in the way that you attach a query to the post request that you're sending to the server so you're always sending post requests to the server so that you have more space where you can put the query and then the server is going to go and resolve the query for you and send back the data that you've been asking for so what does the query now look like for this particular screen essentially we would specify a query like this where we asked for all the conference's and then we can exactly specify what is the data that we need for each conference so we want the name the year the attendees in particular the last three attendees of the conference and then we want the ID and the name of each idea of each attendee so this is really a much much better way because now we can clearly specify on the client side what kind of data we need from the server before we get into the demo let's talk about really important concepts that you have to know when working with Rafael and the first one I just mentioned that's a query so a query you send over when you want to just fetch data from the backend here we have a query where we are asking for one particular conference and we're asking for the name the city and the year of that conference the server response could look like this so we receive a blob of JSON data and this root field there is called data and because that's specified in the graphical specification so every every graphical server response always has to have this root field and then in there we have exactly the same shape in the response that we specified in the query so here we have exactly the same like keys that we now get returned from the server and then we also have the concept of mutations because usually when you're working with an API you not only want to download data but you also want to make changes through the data that you currently have in the database and in graph you'll this is done via mutations so here I have an example for a mutation with which would create a conference so we provide a couple of a couple of parameters to this mutation and an important point about mutations is also that they not only write data but they also always allow you just like a query to also retrieve data so here in the payload of the query we only specify the ID but potentially we could also download the name the city and the year of the conference that we're just creating here this wouldn't be really helpful because we are we already know these values but if you have relations and the conference would be related to more data and maybe it wouldn't be a and create mutation but instead an update mutation or something like this this could be really helpful that you also have the ability to query the data and here is what the server response would look like so again the shape of the response of the server is identical to the mutation that we're sending over we've got the create conference field and the ID field and that's exactly we get in the server response as well alright let's talk about the Apollo client that you can use when you're working with Swift and to work with a graphical API and you can somewhat think of the Apollo client as alum of fire for graph QL IP is so it has three major features at the moment and the first one is static type generation and this really means that at compile time the Apollo client is going to look at all the queries that you're sending over to the server and it's going to generate corresponding Swift types for that so previously or usually when you're building an app you kind of have to write the model types yourself and when you're doing that you have to decide whether like you're really really sure about the data that is going to be returned by the server then you don't have to make the properties on your model types optional but if you have only like the the slightest insecurities about what your server is going to return you have to make your model properties optional essentially because you don't really know if the server is actually going to return that and otherwise you risk that your app is going to crash at runtime and you really don't want that so with graph QL you get all the security that all your data needs are always going to be fulfilled and you don't have to work with optional properties anymore the second part is caching so the Apollo iOS client is going to maintain a normalized cache inside your application so it will store all the data and you can specify like such policies so you can tell the client or you can tell the Apollo client whether you wanted to make a request to the network or only to the cache and it's going to maintain that cache for you and keep your data consistent and especially with graph QL that's a challenge because you potentially can send really nested queries that go multiple multiple levels deep so you first have to kind of normalize the data that you receive from the backend and then you can put it in the cache and that's how you achieve cache consistency and then the third major feature is we're watching so this means essentially that you get automatic UI updates inside your application when data changes so you don't actually have to use like callbacks to update the UI manually but instead the Apollo is client is going to take care of that for you all right before you begin using the before you begin using the Apollo client you essentially have to do three things first you have to install the Apollo client inside your application you can do this with cocoapods or with carthage then you have to download what's called the schema file for your graph QL API so each graph QL API has a schema that clearly defines the capabilities of the API and for the Apollo client to be able to generate the Swift types for you it needs to have access to that schema and that schema you can imagine as being like the contract between the client and the server and everybody has to adhere to that and the third thing is that you have to configure an Xcode build phase and where you setup the static type generation so inside that inside that Xcode build phase you invoke a tool that is going to look at all your graph to your queries and generate the corresponding Swift types for you in the example that I'm going to show right now I have already done these three steps so we can start by writing the code immediately all right before we start though we actually need a graph to our server and that's what I'm going to create first and we'll show you a couple of examples for queries and mutations before we get into the actual Swift probe all right so the first thing we need to do is we have to create our step visible all right so we first have to go and create our graph geoserver what should the data model of our graph your server be we can take a look at the model which I have prepared for this application so we have two simple types we've got the conference type and the attendee type the conference has a name a city a year and the attendees and then we have the attendee type which also has an ID a name and here we have a many to many relationship between the conference and the attendee type so this is the data model that I specified for my application and now I'm going to use the graph cool CLI to generate the server so here I'm just going to call graph cool in it I passed the schema option and in the scheme option I'm passing the model's graph QL file and now my graph your back-end is created for me all right let's take a look around in that graph your server so here I will start a playground and a graph your playground is comparable to a tool like postman for example or the advanced rest client so it essentially allows you to explore the capabilities of your API in a very interactive manner you just fix this all right so here here on the left side I can send queries and mutations to my API and on the right side I will see the server response so if we would go and send the same query that we saw that we saw in the slide before with ID name city and here we won't see much at the moment because we just created our server and we don't have any data stored at the moment so let's actually go ahead and create some sample data in the beginning and one quick side note for the demo so I'm not going to attempt to do any real live coding instead I'm so I have prepared the code snippet and I'm going to paste them into the project and then I'll explain what exactly is going on so let's go ahead and send a mutation to the server to actually go and create the first conference and here I'm creating the swift current conference in 2017 and cologne and let's also go ahead and create swift summit which is going to happen in San Francisco and if we now go back to the all conferences tab and send our query again we see that these conferences are now being returned by that query let's also go ahead and create an attendee so that we already have someone who is able to attend the conference and now we want that this new attendee that we just created actually attempt the two conferences which we created before and for that we are using a mutation that is called add two attendees where we have to provide an attendee ID and a conference ID and I first grabbed the attendee ID from before so that's this one and the conference ID first from Swift conf so now the you the the attendee that we created before is attending Swift conf and now let's also make sure that she's also attending Swift summit all right and now if here we can now change the crew as well and ask for all the attendees and their names and we would see that both conferences have now the the attendee that we just created in their attendees list and we also have like a more table like view of the data that we currently have stored in the database so here we actually have an overview of all the attendees and all the conferences which we created so far alright now we are done with like the graph GL part let's see how we can use it together with Swift so here is my Xcode ah okay so I actually quickly want to show the the app that we are building so now is demo time here is the app so at first we have the register view controller where a user can provide their name here we are going to create the attendee in the backend then we have a list of conferences and then we have a detail view where the user can select this conference and say that they are going to attend the conference and the important part is that the UI here is automatically updating by means of the Apollo client and we will see how exactly that works so that's the app that we're going to build let's start the very first thing that we have to do when we use Apollo is we have to instantiate a global instance of the Apollo client and we do this by providing by providing the endpoint for the graphical API let's see what that was and if we need access to the endpoint we can always get it from the graph cool project right here and I only have to replace the project ID let's see if it builds alright so here we have our global instance of the Apollo client that we can use to send queries and mutations to the backend and because it knows the endpoint of our graph QL API we can just tell it please send this query or this mutation to the backend alright so the first thing we want to do is inside the register of view controller we've got the Save button pressed the action right here and this call to create attendee which we now have to implement and what we have to do here really is we have to send a mutation that takes the name that was given and sends that over to the server so that we can create this attendee in the database and the way how we do this is by creating a new file with the QL suffix inside our Xcode project so here I'm just using the completely empty file template and I'm calling it like the view controller where the mutations increase that I'm about to write are going to be performed so we are going to perform this mutation inside the register view controller dot Swift so here I'm calling this register view controller dot graph QL and inside this view controller we add the mutation that we essentially have seen in the playground before with one little difference and that is that here we are not hard coding the value that we want to send over but instead we're passing a variable because we can only ever decide at runtime what the name of the attendee is that we want to create alright so if I now build the project the build phase that I was mentioning before is going to be invoked so actually let's take a quick look at this bill face and what it looks like so here in the build phases tab of my project settings we see that this check and run Apollo Cochin script is invoked and it takes in the schema Jason so this is also part of my project right here so inside the conference planner project we have the scheme adjacent file right here not sort of that's readable but here it is and so it takes in the schema as an input and it essentially creates this new file that is called API dot Swift which is going to contain all the Swift types that we need to send queries and mutations so it already did that behind the scenes but now I have to go and manually add this file to my Xcode project so I right click on my project add files to conference planner and here we see the API dot Swift file that I was just mentioning and now it's inside the project and so we're not going too deep in what the code looks like that's actually generated because that might be a little bit too complicated for this talk but it essentially generates a number of like really nested structs that you can use to send your queries and mutations but the important point is that we now have this class here which is called create attending mutation that takes a name as an argument and that's really similar to the mutation which we wrote here so what we have to do inside the register view controller now is we have to go and use this mutation and send it over to the server using the Apollo client so let's go ahead and implement Lee create attending mutation we first start an activity indicator then we're instantiating the create attending mutation which I just showed in the API dot Swift file we were passing the name that was provided and then we're using this global Apollo instance that we have instantiated before we calling perform on it passing the mutation and then we can specify this callback here to actually do something with the result the only thing really that's interesting here is that we are storing the idea of the new user and the way how we do this is just with a very simple wrapper around user defaults so if we set this variable we also will save it in user defaults and we return it from there so it's just a very simple way to store the data for this demo and then we perform the segue to the next screen all right so let's see if that actually works let's start the app provide a name in the simulator and then we can also check here in the attendees list if that worked all right so here we've got the screen I'm just putting in my name click Save and we're moving to the next screen if i refresh the attendees here we see that this new attendee has now been created in the backend alright so the next task for us is to load all the conferences that we currently have stored in the backend and the way how we do this is again very similar to what we did before so we first have to specify a query then we have to run or invoke that shell script that is going to generate the Swift types and then we can use these Swift types pass them to the Apollo client and do something with the response so let's go ahead create a new file again this time we're using as a query inside the conference's table view controller so that's this one and we're calling it conferences table view controller dot graph QL and here is where we specify the query that we need to show all the required information so on each cell we want to display the name the city and the year of the conference and the number of attendees that we currently have registered for that particular conference all right if I build the project right now the build phase is going to be invoked again so the Swift types will be generated so here we now have this new type that is called all conferences query that will contain the data after it has been returned by the server so let's actually go ahead and use this right now we can take a very quick look at the implementation of the conference's table view controller so far so that's a very standard implementation of a table view controller we have this array currently the type of the array is just any so we'll see in a bit what we actually have to put there and then we have a computed load where we set the title we hide the back button and we call this load conferences function right here that we still have to implement and in prepareforsegue we'll have to pass the conference that was selected for the detail view controller so let's go ahead and implement load conferences and really all we do here is very similar to what we did before with the mutation we first instantiate this generator type and then we're passing this generated type to the Apollo instance calling fetch and retrieving the data or retrieving the returned data from the result here and then assigning it to the conference's to the conference's array right here but what is actually the type of this thing here now this is now a little bit weird because the the Apollo client is going to create really nested structures for the types that we have set and here it's actually the all conferences query data all conference type and we'll see in a bit how we can make that a bit a bit nicer but for now let's go with this so we now have the correct type right here let's also make sure that on the conference cell we also have the correct type because there we have the type not ready either and then in the dead set property observer of our conference right here we also want to make sure that the UI gets updated once the conference is being set all right so let's go ahead and run this and if I didn't forget anything we should now see the conference's that I created earlier in the playground in the table view and there they are so we've got the Swift conf and Swift summit and both at the moment have one attendee which is the attendee that I also created in the playground so everything is expected until here but what's really bothering what's really bothering me right now is this weird type right here so the way how we do this nice how we can do this a bit nicer in the Apollo client is by using a graph GL feature that is called fragments and I first quickly want to show what a fragment is again in the playground so before we had this we had those all conferences query here but sometimes it can be convenient to define like reusable sub parts of a query we just have a set of that you hide with the special with a specific name essentially so here we are going to define a fragment that is just going to contain these fields and that we can reuse in different context so here I can call this conference details on the conference type and I put all the fields into that fragment that we had in the query before and if I want to get the same results I just use the dot-dot-dot conference detail syntax so dot dot and the name of the fragment to achieve the same result so really what's happening here is that the server is simply going to replace this with the fields that we have specified here and this graph QL feature these fragments now allow us to to work with the Swift types in a bit of a nicer way so we can go ahead and define the same fragment we just saw in the playground also in our dot graph QL file right here so I go ahead and build a project and now if we check API dot Swift we just got a new top-level type that is called conference details here it is so now I can replace this weird type that we saw before simply with conference details and it will just have the same properties so let's go into the conference's table view controller replace it here then in the conference cell also replace it here and then we just have to fix one more thing and that's just a pattern that you are going to get used to once you start working more with the Apollo client that now the conference's actually contain the fragment as properties as well so we actually have to go and map over the conference's and retrieve the fragments from them and that's what that looks like all right so we just retrieve the conference details and we can assign it and now everybody should so now it's just it should just work in the same way it did before all right so here it's still running and one more thing which I'm going to do right now for convenience is I am going to add an extension on the conference details type and I'm not going to do that inside the API dot Swift file because this will get changed when we build every time and if I make any manual child if I make any manual changes to that file and they will be gone after my next build so I write the extension in a different file and this is just really a convenience function to know whether a particular attendee is attending a conference alright so now we want to implement the conference's detailviewcontroller if I click on a conference right now we just see the values that I have specified in the storyboard and now we actually want to go and pass on the real data to that so inside the conference detailviewcontroller let's take a quick look at that we have the conference that we're going to show and then we also have the attendee list that is going to be rendered inside a table view and down here we just again have a standard table view implementation we don't know yet the type of the attendees right here but we know that this conference is going to be of type conference details all right and then the is current user attending we're also going to set so it's just again a convenience or it's just a convenient way that is going to help us with UI later on all right we are also going to implement the update UI function where essentially we just take the data from the conference and assign it to the labels and to the button that we have on the details screen and finally if we navigate to that view we actually have to go and tell the detailed view controller which which conference has been selected so we do this right here and prepare for segue all right so this already should render the selected conference in the detail screen so let's go ahead and run the app once more select a conference from the table view and see if we actually see the right data on the detailed screen so if I click on Swift summit here we see that now the Swift summit is actually being rendered we don't yet see the list of attendees though because for that we actually have to make an additional query with some information that we want to display because we also want to display how many other conferences each attendee is actually going to attend so here is the query for that let's go ahead and create a new file for the conference's detailviewcontroller conferences detailviewcontroller graph GL so again we are following the same pattern at first we have to define the query or mutation inside a dot graph QL file then we have to build and then we pass the generated type to the Apollo client all right so here is the conference query so we were asking for a specific conference by passing an ID and then we're also asking for the attendees but for each attendee we want to have the name and we want to know how many attendees this how many other conferences this attendee is going to attend and that's exactly the information that we specify right here in the query so now we can go ahead and load the attendees so let's go to the detail view controller right here we can now set the type this is actually going to be of type attendee details so the the type of the attendees array that we want to display then we are implementing the cell for row at index path in the tableview down here essentially what we do we just retrieve the correct attendee from the array then we're assigning it to the label it's not a custom cell it's just like a standard table view table you sell this time and we put the string on the detail text label how many other conferences this attendee is going to attend and then finally we actually have to go and load the attendees and that's what we're doing inside the lowered attendees method so exactly the same way that we did before we use the conference conference attendees query that was generated for us we're passing the ID of the selected conference we're passing this query to the Apollo client by calling fetch on it and then we're using the results and assign them to the conference and to the attendees right here all right we've got two more features that we need to implement and the first one is we actually need to be able to change the attending status so we have to implement like two more mutations to attend and not attend the conference and then also the automatic UI updates using query watching but we're almost done so bear with me here all right so now we also see the attendees for each conference so the query which we are sending is successful so let's go ahead and create the mutations again I prepared the mutations beforehand we have to use them in the conference details view controller so this is actually the same mutation that we saw on the playground before it's the Add to attendees mutation we're passing a conference ID and in a attendees ID and we have the same for removing so we toggle the status we toggle the attending status let's build the project so that the types are generated and implement our ID action with the correct mutations here so in the conference's details you can when the attending button is pressed we want to toggle the state so we first ask is the current user attending if it is currently attending then we're going to send the nut attend conference mutation and if they are they already attend the conference or they if they current don't attend the conference then we send the attend Conference mutation and we just passed a mutation to the Apollo client again all right so let's run this and see if it works all right so let's go and now clicking the button right here I will attend the conference we don't really get any visual feedback but from what we just implemented we at least assume that the mutation was sent to the server so let's do the same with swift summit and if we now restart the application we should actually see that the current user is now attending both conferences and we don't see the red cross anymore but instead the green checkmark because we are now attending the conference and that's exactly right and now both conferences also have two attendees and they're both being displayed down here in the table view so the last bit that we want to implement is the query watching the automatic UI updates and for that the Apollo client provides the graph QL query watcher that we have to use for that that essentially we'll keep an eye on the cache and on the mutations that are going to be performed and whenever a mutation is performed that touches an item from the cache it can automatically infer which object or which object in the cache it should update and this will also automatically trigger a UI update so let's go ahead in the conference's detailviewcontroller we want to watch the the conference attendees query have to import apollo for this and then we only have to change the call to Apollo fetch right here where we are passing the query instead of fetch we're using the watch method on Apollo and the result of that we are assigning to the conferences attendees watcher which I instead were which I declared up here then we need to do one more thing and that is we have to tell the Apollo client how it should identify the objects in our cache and since we are using unique IDs for our objects we can just do this and that's just a really standard way of doing this you don't really have to understand why we have to do it right now so that should be good and if we restart the app now then we should see the UI in the details view controller update automatically but we still don't see the UI in the table view controller update so let's verify that first if I now click here I won't attempt the conference we see that everybody we see that all the UI elements inside the details view controller update but if we go back we still have the attending status right here so we also have to make sure that we're watching the second query the all conferences kemuri in the table view controller that's what we're doing right here again we're using the watch method assigning the result of that to the all conference's water and now again we have to import Apollo and now the UI in the table view should be updating automatically as well incredible this excitement here all right let's try I will attend the conference detail view controls updating table view controllers updating the other way around exactly the same all right so that's how it works you've seen like the the basic features if there was a little bit too fast for you which I can totally understand like this was a lot for the chest for the session after lunch I can recommend a couple of resources to you so if you want to learn more about graph QL you can check out the how to graph QL tutorial which is going to give like a recent basic introduction into graph QL like really the fundamentals but it also has a lot of hands-on tutorials that you can do mostly for web technologies at the moment though so you don't have any native tutorials on that website but there is the getting started with graph QL tutorial on the Raven Dalek website so it actually uses the same example which I just showed in the demo so it'll be somewhat familiar to you already and then if you want to have like a more conceptual talk about what graph QL actually is and why it's interesting for mobile then I would recommend you this talk by the author of the Apollo client actually bringing graph QL to high us and if you want to stay really up-to-date about what is happening in the graph community and ecosystem I can recommend you the graph QL weekly newsletter and the graph QL radio podcast alright that is all I have thank you so much for your attention happy to take questions all right for the question yeah I need I need help from from and oh yes but the first one is just here so I can give you the mic okay how to how you get position see on the client if you like - is it not designed to have consistency on the client a really good question so the Apollo client at the moment does not have persistency so the cacistis in memory but I think that there are at least some ideas in the community around the implementation of the Apollo client that are already trying to figure out ways how you can do this but the Apollo client itself is still relatively young so I think they released like the initial version last year in November and right now they're on version 0.6 so it's still really young and like we for like a lot of use cases you still have to find the right ways how you can solve these and I think that persistency is part of that like I usually have alright so how you can achieve like pagination and filtering and sorting inside the API essentially like how do you get these kinds of capabilities so with graph QL in general there is not really a solution for that it really depends on the implementation because graph QL itself is only a specification for this query syntax that we saw but it doesn't really tell you how you have to design your API so that is still up to you as the API developer how you want to expose all this functionality I can tell you how we add graph cool out doing this if you're using like the graph cue the graph QL API that we provide so for each list that you're requesting you can specify exactly these parameters that you were just mentioning for filtering for ordering and for pagination so here I could here I could now go and specify a filter if I wanted to have the conference's which are happening in Cologne I just send like this query with this filter here and it would only return swift cons but not Swift sum it anymore and we are we have more of these of these filtering capabilities here so you could also have like a string contains or is inside an array or something like this so we really provide you with all these mechanisms out of the box and if you want pagination exactly the same we support limit offset pagination so you could skip the first hundred and then load like hereafter and if you combine skip and after you essentially get this limit offset pagination capability the Apollo iOS client I don't think that they really support that at the moment so you probably have to figure out some way how you can do that with it I think on the web they are already a bit further so I think their pagination is supported by default I don't think that's already implemented in the in the iOS client yet maybe one last question because we're running a little bit of time for the panel that's a really good question right right right so Facebook actually when they announce graph QL what they claim is that since they started using graph QL they have never really needed to version their graph GL schema so the graph GL schema defines the API and they said they don't really have to version it which for most applications is not going to be feasible so you want to have some kind of versioning system and what's really nice about graph QL is that on the server side you can have really good analytics about what data is being requested so when you see that specific fields are not being requested anymore and you can tell the clients that you know are accessing your API hey we're going to deprecated this field you can put that into the schema so the clients are aware of it you can like know when clients are not as accessing specific fields anymore and then you can remove these fields as the short answer we can talk a bit more about it after I'm the talk afterwards all right we we keep keep the other question keep the question for the panel menu because we'll speak about this stuff again later for the moment I will ask you to give Nicolas a round of applause okay and I have stickers as well grab cool and graphical stickers if you want some sticker stickers and yeah and go outside for like 10 minutes or something and then we come back later with James all right
Info
Channel: SwiftConf
Views: 4,289
Rating: undefined out of 5
Keywords: SwiftConf17, graphql, graphcool, facebook, api, rest, server, client, iOS, SwiftConf
Id: 4o59zEna9gQ
Channel Id: undefined
Length: 51min 3sec (3063 seconds)
Published: Mon Sep 11 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.