Socket
Socket
Sign inDemoInstall

@developedbyant/shopify-api

Package Overview
Dependencies
1
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @developedbyant/shopify-api

Simple and fast package to query and mutate data from shopify, auto generating types.


Version published
Maintainers
1
Created

Readme

Source

Shopify GraphQl Package

Simple and fast package to query and mutate data from shopify, auto generating types

Import client

import Shopify from "@developedbyant/shopify-api"
const storeUrl = "https://shop.myshopify.com/"
const StorefrontAccessToken = "12232344323kj432323"
const shopify = new Shopify(storeUrl,StorefrontAccessToken)
// Make a query
const query = `
    query getProducts {
        products(first: 5){
            nodes{
                title id handle
            }
        }
    }
`
// Make request, the response return ok:true|false, if true response return { ok:true,result:any }
const response = await shopify.request(query,{ type:"query",method:"products" })
// Always check if everything went fine
if(response.ok){  
    const data = response.result
    console.log(data) 
}

Import server

When import server, you can generate type for result

import type { HomeProductsResult } from "./types"
import ShopifyServer { type GenerateType } from "@developedbyant/shopify-api/server"
const storeUrl = "https://shop.myshopify.com/"
const StorefrontAccessToken = "12232344323kj432323"
const shopifyServer = new ShopifyServer(storeUrl,StorefrontAccessToken)
// Make a query
const query = `
    query getProducts {
        products(first: 5){
            nodes{
                title id handle
            }
        }
    }
`
// Make request, the response return ok:true|false, if true response return { ok:true,result:any }
const generateTypeConfig:GenerateType = { name:"HomeProductsResult",path:"./test/types.ts"}
const response = await shopifyServer.request(query,{ type:"query",method:"products" },generateTypeConfig)
// Always check if everything went fine
if(response.ok){  
    const data:HomeProductsResult = response.result
    console.log(data) 
}

Keywords

FAQs

Last updated on 12 Jun 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc