Giter Club home page Giter Club logo

go-shopify-graphql's Introduction

  • ๐Ÿ‘‹ Hi, Iโ€™m Kirill (@r0busta)
  • ๐Ÿ‘€ Iโ€™m interested in building cloud native solutions to common business problems
  • ๐ŸŒฑ Iโ€™m currently learning Rust, Redis and Kafka
  • ๐Ÿ’ž๏ธ Iโ€™m looking to collaborate on building cloud native software and tools for ecommerce that would help merchants escaping the Shopify lock-in
  • ๐Ÿ“ซ How to reach me: ping[dot]kirill[at]gmail[dot]com

go-shopify-graphql's People

Contributors

ferrallv avatar ksdfg-navana avatar markovantony avatar r0busta avatar vinhluan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

go-shopify-graphql's Issues

Question: Mutate

Hi, thanks for any help you may offer. Any idea how to submit a Mutate request?

I followed your example for the Products query at it works! However, I need to mutate using this graphql mutation quide: https://shopify.dev/docs/admin-api/graphql/reference/mutation/inventoryadjustquantity?api[version]=2020-07

I looked here at the mutations example but surely I missed something or wrongfully applied the logic because I cannot get it to work: https://github.com/shurcooL/graphql


import (
	"context"
	"fmt"

	shopifygraphql "github.com/r0busta/go-shopify-graphql"
	"github.com/shurcooL/graphql"
)

func main() {
	// Create client
	opts := []shopifygraphql.Option{
		shopifygraphql.WithVersion("2020-07"),
		shopifygraphql.WithPrivateAppAuth("myappkey", "myapppass"),
	}

	client := shopifygraphql.NewClient("myshopify", opts...)

	type InventoryAdjustQuantityInput struct {
		InventoryLevelId graphql.String
		AvailableDelta   graphql.Int
	}

	var m struct {
		InventoryAdjustQuantity struct {
			InventoryLevel struct {
				ID graphql.String
			}
		} `graphql:"inventoryAdjustQuantity(input: $input)"`
	}
	vars := map[string]interface{}{
		"input": InventoryAdjustQuantityInput{
			InventoryLevelId: graphql.String("gid://shopify/Product/5544934473882"),
			AvailableDelta:   graphql.Int(5),
		},
	}

	err := client.Mutate(context.Background(), &m, vars)
	if err != nil {
		panic(err)
	}

	fmt.Printf("Inventory adjusted %v\n", m.InventoryAdjustQuantity.InventoryLevel.ID)
}

Challenges working with products

Hi there,

I've been trying to get a product going using your library. Thanks for building it and putting it out here on github!

I'm getting this failure on almost any operation that I do:

[leigh@host shopify-updater-v1m]$ go run .
panic: get bulk query result URL: Bulk operation didn't complete, status=FAILED, error_code=ACCESS_DENIED

goroutine 1 [running]:
main.main()
        /home/primax/workspace/shopify/shopify-updater-v1m/main.go:16 +0x156
exit status 2
[leigh@host shopify-updater-v1m]$

I've validated that my client works with other operations such as pulling from collections. My scopes look right. The token has been tested with other tools and it works.

Here is the code I'm using:

package main

import (
	"fmt"

	shopify "github.com/r0busta/go-shopify-graphql/v6"
)

func main() {
	// Create client
	client := shopify.NewClientWithToken("shpat_xxxx", "my-dev-store-1")

	// Get all collections
	products, err := client.Product.ListAll()
	if err != nil {
		panic(err)
	}

	// Print out the result
	for _, p := range products {
		fmt.Println(p.Variants.Edges[0].Node.Title)
	}

}

I've also attempted using Product.List("query") using queries I've tested using graphiql, same error.

Could you please point out what I'm doing wrong? I've looked into the bulk operations go file but I'm not sure if I should be using that at all.

Thanks!

Leigh

Edit: I forgot to mention, I'm authenticating via token as I was never able to get authing with NewClient to work.

Getting issues while using products.Get service

		_ = graphqlclient.NewClient("{hidden}", graphqlclient.WithToken("{hidden}"), graphqlclient.WithVersion("2023-07"))
		gClient := shopifyGraphql.NewClientWithToken("{hidden}", "{hidden}")

		// If no more products, exit the loop
		if len(prods) == 0 {
			break
		}
		opt = pagination.NextPageOptions

		// Print all fetched products
		for _, product := range prods {
			resp, err = gClient.Product.Get(context.Background(), strconv.Itoa(int(product.ID)))
			log.Fatalf("%v", err)

I am trying to fetch details of the product via graphQL but stuck at

level=fatal msg="query: Variable $id of type ID! was provided invalid value"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.