Over the past few years, REST has become the only way for designing web APIs. However, there are things that make REST very inflexible. For example, you cannot control how much data you can retrieve or you can't specify the only data that you wish to retrieve, etc. This happens in Shopify app development as well. If you want to get a product using REST API, all of the data about your products will be sent to you. This makes REST very heavy and slow to use. So, that's why GraphQL was created, to cope with the need for more flexibility and efficiency.But, we're not going to focus on the difference between REST and GraphQL. Instead, we're going to learn how to create products using GraphQL mutations and vanilla PHP. Video Tutorial If you prefer watching video tutorials, then the video below is for you. https://youtu.be/73H_5qY3W9A Otherwise, feel free to keep reading the content below. Getting Started If this is your first time learning how to make Shopify apps using vanilla PHP, then we highly recommend reading through our guide here. We also have a ton of videos covering Shopify app development, so before you proceed, make sure that you have a local web server and a Shopify app installed in your development store.Before we start using GraphQL mutations in PHP, we need to create a function that will allow us to make API calls. GraphQL API Call Function Create a new PHP file called functions.php and copy the following code: In the code above, we referenced the functions.php so that we can use the graphql() function.Now, make sure that you have your access token in the $access_token variable. If you don't know how to generate an access token, then watch our tutorial here. https://www.youtube.com/watch?v=qUORn94AxRM Let's assume you already have your access token, we can now proceed and use the GraphQL function to create products. Creating Products using GraphQL Mutations In the same file, create a new variable and use the function graphql() like what we did below. In the 3rd argument, we applied an empty array, that array is where you're going to apply the query/mutation.So let's create a new variable and call it $query or whatever you want. Then, in this variable, we will create an array and its key SHOULD be set to query. Again, the key SHOULD be set to query and not something else. Then, we're going to use that variable in the 3rd argument of the graphql() function. Next, let's use mutations.Update the array to the following: In this mutation, we used the productCreate field and this field requires us to provide an argument input so there we provided a title and a descriptionHtml. After the product is created, the mutation will then return a field called product and in that field, we create retrieve data about the product like its id, title, tags, images, etc. To learn more about the product field, click here.That's it! If you run your app, it should give you the following response. { "data": { "productCreate": { "product": { "id": "gid:\/\/shopify\/Product\/1234567890" "title": "Vanilla PHP & GraphQL" } } } }