So all three of these are in separate repositories and they are deployed separately. And the first version of these web1, api1, and app1 all implement the user type as seen here.
Now the first stage add is pretty straightforward. We're going to add the schema fields that need to be added. In this case, we're going to add the first name and last name to the user type.
The next stage deprecate, you would usually do it together with add. But in this one, we're going to deprecate any fields we might want to remove in the future. Here we've added the deprecated directive. We use the deprecated directive to add a deprecation notice to the name field in the user type.
Now when we're finished with all our changes, we will release a new version of the GraphQL API to api2. Now, api2 is still compatible with app1 and web1 which means this is a backwards compatible change.
The next step is the migration step. Now in this step, you have to go through all the clients, everything that's using your GraphQL API, and update them to use the new API. Then we'll go to the Website and the app. We'll do the change and we'll publish the new versions and ensure all of our users are using them.
Now when you're confident that no-one is using web1 and app1 any more, and you've published web2 and app2, then it might be safe to remove the field. So here we can remove the name field that was deprecated from the user type and when we're finished we will deploy the new version of the API to api3. Now api3 is not compatible with web1 and app1, they would still get an error, but if no-one is using them, you've already published the change, they will be using web2 and app2, then that is a fine deletion to make.
Now because I build mobile apps, I wouldn't be a mobile app developer if at this point I didn't go on a tangent on why this is so much harder on mobile applications. On a higher level, this is what deploying websites and APIs looks like. You've finished your version 1, you're going to upload it to wherever you release it, say AWS, it will become available to users, and 100% of your users are going to use it.
Now when it comes to releasing v2, when you finish coding it, you're going to upload it to AWS, you're going to make it available and instantly all of your users are going to switch over and 100% of your users will be using v2 and no one will be using v1. When you finish v3, you'll release it, 100% of your users will immediately be switching over.
Now this seems pretty obvious but the fact is, this isn't at all how it works for mobile applications. This is what deploying a mobile app looks like. When we've finished our v1, we're going to upload it to the stores, we're going to get an approval, and when we've got the approval we can publish it to the app and play store. And because it's the first ever version of our app, 100% of our users are going to be using it.
Next, when we're ready for v2, we're going to release it to our stores, we're going to get it approved, we're going to release it to our stores. We're going to, it actually takes time so we're going to go away for two weeks, we're going to look at the stats after two weeks, and we'll see that maybe 60% of the users will use it, will be using it. And 40% of users are still using v1.
Comments