 So as, as I mentioned before, queries are for reading and mutations are for writing. So when you're dealing with some sort of information in DHS to you can read that information you can you can figure out what the name of an indicator is or the name of the current user. But you can also change those things so if your user has permission to change the name of an indicator that can change the name of that indicator or the formula that is used to calculate that indicator. Similarly, every user has access to their own to edit the information about their own profile so that's things like their email address or their phone number or their description or or their name. The user can change the those on their own user. And so I'm going to talk a little bit about how to do this with data mutations. In the rest API world that would be a post requests to create something a put request to replace something. It's a delete request to delete something and maybe a patch request to to edit something partially. And so these are those four kind of HTTP verbs that you might be used to do this with rest API is just by themselves. And then we can also do the same things through data mutations. And so I'm going to demonstrate that quickly again I'm these are the slides that I showed before but let's let's go ahead and run this this particular example. In a way that will. Yeah, in our system so that we can see how that works to do that. I'm going to go back to my app runtime query playground. I have to get zoom out of the way so that I can see it. I can see here that we have a mutation option down here on the bottom left. This is a query that I've already written so I don't want to change that to a mutation, but I can create a new tab, which has a new query. I've switched to mutation since I haven't edited this one it gives me the default, which is to update the introduction of the current user introduction is kind of like description or your, your, your profile, and I'm going to say hello world. So I'm actually going to create a second tab here and this one's going to. So I can close that first one that I had open. I'm going to rename this actually I can rename it so this is going to be edit current user mutation. This is a handy way to keep track of the different queries and mutations that you might be playing around with or or using similar to what you might do in postman. View current user. So this is a query. I'll say query here. So the view current user query if I click execute, it's going to fetch the name ID email and introduction of this current user, the one that whoever I'm logged in as, and you'll see that the name the introduction is hello world because I've already run this mutation in the past. I can change that so let's say. Bonjour. So now we can see if we do this again, we got a response on the right side there so this is a mutation again. The type is update because we're actually replacing something in this me resource. And I'm changing my introduction to something in French. If I now I click. So, sorry, I clicked execute here, and the response on the right is the whole me resource that's not the case for a lot of other metadata endpoints but for the current user that's what you get as the response to your mutation or your poster put request in this case. Now I'm going to go back to my query and click execute so I can get this query. And I have the, the new introduction that came back because it has been edited in, in the DHS to database. And now everyone can see my introduction in French, if I would like to. I wanted it to be front Spanish can do that change again. And now if I run this query again, I get the same thing in Spanish. Now, let's talk about some of the other types of mutations that we might try to use. I'm going to go ahead and close my current user edit and delete or edit and view mutation and query. I'm going to create another mutation here so I'm going to edit this and say this is going to be my create, we're going to create a visualization. This is going to be a create me to create visualization music mutation so my resource is going to be visualizations. I'm going to be going to be create. And I need some data for a visualization but I'm not really sure what, what I need to provide what what data I need to give to the visualizations endpoint. So let's go ahead and make another query. Visualizations. Let's go say, you visualizations query. I'm going to get, I'm going to get all the fields for now just so that I can see what's what's there visualizations with an s. So our page, we again where we have 278 visualizations that are saved here. I'm just going to go and pick one of these so this one is a type single value, which is a very simple visualization type so I'm going to use that one because it's the easiest to to use. And I'm going to say visualizations I'm going to add an ID here. So just to make this a little bit more simple. So now we don't have a list. Did I mistake that. Yeah, maybe I had the wrong, I copied the wrong thing. So now I have this single value visualization here. I can see that it's got a lot of different fields, most of them are empty. It turns out that the only fields that I really need for the visualization are for a single sorry for a single value visualization or name. And put this on another line type. A single value visualization. Technically, this is this should be all that I need for a to create it. Obviously we would need to specify some more information as well to actually be able to use this visualization. So if we go ahead and find another one that isn't one of these test ones. Let's try, let's add a filter just going to go ahead and demonstrate how to use some of these things. Let's say filter type equals single. And let's execute that. So now I have a list of all of the single value. Single value visualizations in my system. And most of these are all tests, which means that there weren't any probably before we started playing around with this. Let's see if we did. Let's if we did this instead, going to copy this visualization and say log out. I'm going to log in instead to another system. So I'm going to go to a different work. Just in the meantime. Robert asked if when doing API queries, if there's a way to specify counts or returned objects, similar to SQL select counts. That is a very good question. That is a very good question. I believe there is a way to do that today. If that's something that's useful for certain applications that that would be a very good request to make. But I don't believe there's a count feature today. There might, there might be. Let's let's go ahead and explore this together. I haven't used it myself in in a while if it's the case. Before we go to docs.djst 2.org. When you go back to the main page here, you can click on develop explore developer documentation, click using the API on the left side here. And then there's a bunch of these different sections. So this will tell you how to authenticate with the API tells you a lot of the things that in much more detail that that I went over today. Structure periods, all sorts of things like this, as well as how to use the different scheme codes and things and paging and filters and fields and translations, lots of lots of information here. Let's go ahead and search for count. See if we can figure out what that is. We can do it for events. I don't believe that you can do it for metadata, but we can take a look at that. Maybe for data elements, some other things. So I think the answer to your question would be, I don't think it's supported for metadata endpoints. You can get counts through analytics quite easily, which we're not going to cover today. We'll cover that in the next workshop. And that is something if that's something that's quite useful that we could look into adding in the future. So I'm going to go ahead and add this here. Oh, I don't have. Actually, I'm not going to I'm not going to demonstrate this with in this way. So I was trying to try to log into a different server that had actually I will do it just so that everyone can see. I'm just going to log into this. If you have a DHS to instance, and you want to use the data query playground with that DHS to instance you have two options. Your first option is to go to system settings. And as Deborah mentioned before, and you can add this URL run time that DHS to that and you can add that to this list without the slash. The other option. This is maybe getting a little bit off topic, but the other option is to go to the app management app, which you can also use to install your own applications. Go to the app hub and search for playground. So we have this data query playground right here, we can install version one. It will install from the app hub and install it successfully. And then I can actually, this is actually running on my DHS to instance in in this particular version. And it has the same tool. But I added this to the course list. So I'm going to go ahead and run it here from debug. Right. And now I have this query that we were making before visualizations. I'm going to do filter type equals single. Okay, so here we have some some real. Maybe, maybe some real ones, maybe not some real ones. Actually, these are all tests as well. Maybe they actually work. Anyway, we're just going to create a new test visualization with type single value. And that's what we were here to do from the beginning. So let's do create visualization mutation, call it that this query we're going to call view visualizations query, create visualization mutation is going to be a mutation. And we're going to do it on the visualizations resource. We're going to create a new visualization and the data that we need as we mentioned before is a name. So we're going to call this one. I am not a test, even though it is a test, or we're lying here, but that's okay. In our, if we looked at the fields that we wanted here the other one that we wanted was type, and we needed type to be single. So this is going to create a new visualization called I am not a test. And it will go ahead and do that so we can see that this was created we have a 201 which means created status code. We also have the ID of the object that was created. Now if we go back to our view visualization query, we're filtering by type equals single value. Right now there's nine of them before before I added a new one. Now we have 10. And you can see this I am not a test here up at the top. We could also if we wanted multiple filters we could make this an array. And just demonstrating a lot of different features of data queries and app runtime here so hopefully it's not too confusing, but we could say display name equals. I am not a test. This should work. And there we have our list of all the display name or all the visualizations that have a type of single value and are named I am not a test. If we then created another one so let's go ahead and execute this two or three more times. We can have multiple visualizations with the same name actually in this case sometimes that's not the case depending on the resource that you're talking about. Now we actually have four five four different visualizations that we have created that are all called I am not a test. We could also do 234 create that one, and we could change this equal to a dollar I like, which means we are going to also receive, I am not a test 234. So this is just an example of a create visualization that lets us create a new thing. Let's go ahead and look at the so that last one that I just created called I am not a test 234 ID is TUL e etc. I'm going to put that under ID here in my mutation. I'm actually going to create a new mutation here. I'm going to call this one edit visualization mutation resources going to be visualizations ID is going to be the ID of the one I just created type is going to be update. And in this case, I'm going to use update and I'm going to say partial true, which means that I'm only going to update a part of the thing that I'm that I'm trying to edit. I'm going to change the name. So previously it was I am not a test 234 and I'm going to change it to I am a test. So we go ahead and do that update. Actually, this I think partial doesn't work on this visualization so as I mentioned in the slides, partial only works on certain endpoints so be aware of that. So let's go ahead and replace this whole object, we're going to say type is going to be single value. Okay, when you use an update mutation you have to specify all of the fields so you should fetch all of the fields before you update them. Now let's do that, we have an okay 200 response. And we'll see that if I execute this again we had five before that start with I am not a test. Now we only have four because this one says I am a test so we say I am a test instead. And we get the one that we just edited. And so this is how you would do an update mutation. I can also do a delete mutation. So, this is going to be delete visualization mutation. And we're going to say visualizations is the resource again type is going to be delete ID is going to be that ID that we were using before. We don't need any data for a delete mutation. Let's go ahead and delete it. Okay, so our visualization which we previously had here called I am a test. No longer exists. There are no no visualizations in this list at all. Now let's do I am not a test. Let's see which other ones we have here let's clean up after ourselves. So we still have four visualizations here. And for each of those put that ID into the visualizations delete query, we've now deleted this one let's show that that is gone and do it again. And show that that one is gone. Two more to go. And show that that one is gone. And now we're going to delete this last visualization that we created. So now we have looking for anything with display name I am not a test. Nothing is there. And that is all we have. Okay. That is a quick overview of mutations. There is an exercise that Deborah did you want to introduce the exercises you want me to. Yeah I can introduce the exercises but before that, there is a question on slack. Yeah. So what happens when the resource doesn't support duplicates, while using create, would it updates the resource or throw an error. Good question. So if you're using a create mutation so if we go back here and we have this create visualization mutation, and we said that name name does does support duplicates in the case of visualizations. I believe indicators does not. Let's let's think of an easier way to do this. Actually, so let's see, let's let's create a visualization here called. A test single value. We just created one here I'm going to look for ones that have I am a test. What I'm going to do here to demonstrate this is I'm going to try to use ID in the create. I think this will throw throw an error. So ID needs to be unique. So we have an error there so if something needs to be unique and you use a create mutation you'll get an error response. So in this case it's a 409 error it gives you some details in the in the object here so found an object for given reference, but import is a modus create so identifier was you ID means that the ID that we're trying to import here already exists. So you will get an error if you have a unique field that you are trying to update it won't it won't update the existing mutation in this or the existing object in that case. Good question.