Expert Advice

How to run your first GraphQL query and set up afoundation for your Shopify app development journey

Devender
|
November 1, 2023

Before we begin, I am a Shopify Front End Developer. I have worked mostly on theme customizations, custom theme builds, building features using JavaScript and Liquid, and many more. However, recently, I wanted to step up a bit in my development game and give a shot to app development. BUT... the official Shopify documentation is a lot to deal with; they kind of force us to use their boilerplates with lots of code that makes things really hard to understand.

So after days of stumbling across the web, I somehow got an overview of how Shopify apps work in a nutshell. Finally, I was able to run my first query in my basic node App and make a change in my product admin. Yay! Let's dive in!

Before starting the tutorial, I would like you to focus on the below URL structure carefully.

You will notice a set of parameters like →

  1. url of shop → https://mystore.myshopify.com // for_example
  2. shopify syntax → /admin/oauth/authorize
  3. client_id=fe0710b263922ec2a5ec206dbd8cf7ac // for_example
  4. redirectUri = 'http://localhost:3000/auth/shopify/callback'; for_example
  5. response_type=code
  6. scope = 'write_script_tags write_themes';
  7. state=24abdb4a773b68d59d0e6b95355b4eceb2d9af80e12209fb // for_example

Lots of things, going right? Don’t worry I will go through each step one by one, and we will build a permission URL in the process to make first URL redirect ( Shopify Authorization Page ) so that the merchant is able to click on install button and authorize the request.

PS: It’s assumed that you have created an app from partners dashboard and have stored client ID and client Secret secretly.

Our primary goal will be to create a URL that resembles to a structure like given above to let merchant install the app and initiate authorization process.

In my Node JS example

I have written a function which helps us to create a URL like this.

Now the URL is built successfully. You can proceed to “/install” to get redirected to the permission URL.

After the merchant installs the app and grants permission, Shopify redirects back to the callback URL configured in your app

( /auth/shopify/callback ) and perform required operations to get the relevant data like code, hmac, state and shop.

Now, we are able to access the code that is then used in exchange of an access token. We can now use it to make requests to the Shopify API on behalf of the store owner.

Making the first Query


I hope this article will definitely set you up for your shopify app development journey.

References →

  1. https://shopify.dev/docs/apps/auth/oauth
  2. https://gavinballard.com/shopify-oauth-flow-for-dummies/

7,93
15,86
23,8
31,73
39,66
47,6
55,53
63,46
71,4

Before we begin, I am a Shopify Front End Developer. I have worked mostly on theme customizations, custom theme builds, building features using JavaScript and Liquid, and many more. However, recently, I wanted to step up a bit in my development game and give a shot to app development. BUT... the official Shopify documentation is a lot to deal with; they kind of force us to use their boilerplates with lots of code that makes things really hard to understand.

So after days of stumbling across the web, I somehow got an overview of how Shopify apps work in a nutshell. Finally, I was able to run my first query in my basic node App and make a change in my product admin. Yay! Let's dive in!

Before starting the tutorial, I would like you to focus on the below URL structure carefully.

You will notice a set of parameters like →

  1. url of shop → https://mystore.myshopify.com // for_example
  2. shopify syntax → /admin/oauth/authorize
  3. client_id=fe0710b263922ec2a5ec206dbd8cf7ac // for_example
  4. redirectUri = 'http://localhost:3000/auth/shopify/callback'; for_example
  5. response_type=code
  6. scope = 'write_script_tags write_themes';
  7. state=24abdb4a773b68d59d0e6b95355b4eceb2d9af80e12209fb // for_example

Lots of things, going right? Don’t worry I will go through each step one by one, and we will build a permission URL in the process to make first URL redirect ( Shopify Authorization Page ) so that the merchant is able to click on install button and authorize the request.

PS: It’s assumed that you have created an app from partners dashboard and have stored client ID and client Secret secretly.

Our primary goal will be to create a URL that resembles to a structure like given above to let merchant install the app and initiate authorization process.

In my Node JS example

I have written a function which helps us to create a URL like this.

Now the URL is built successfully. You can proceed to “/install” to get redirected to the permission URL.

After the merchant installs the app and grants permission, Shopify redirects back to the callback URL configured in your app

( /auth/shopify/callback ) and perform required operations to get the relevant data like code, hmac, state and shop.

Now, we are able to access the code that is then used in exchange of an access token. We can now use it to make requests to the Shopify API on behalf of the store owner.

Making the first Query


I hope this article will definitely set you up for your shopify app development journey.

References →

  1. https://shopify.dev/docs/apps/auth/oauth
  2. https://gavinballard.com/shopify-oauth-flow-for-dummies/

Talk to an expert
Discuss the project for free
with a Storetasker Expert
From an Expert
Devender Sharma
7,93
15,86
23,8
31,73
39,66
47,6
55,53
63,46
71,4