malomohq / shopify-graphql-elixir Goto Github PK
View Code? Open in Web Editor NEWElixir client for the Shopify GraphQL Admin API
Home Page: https://hexdocs.pm/shopify_graphql
License: MIT License
Elixir client for the Shopify GraphQL Admin API
Home Page: https://hexdocs.pm/shopify_graphql
License: MIT License
Dependabot can't evaluate your Elixir dependency files.
As a result, Dependabot couldn't check whether any of your dependencies are out-of-date.
The error Dependabot encountered was:
** (FunctionClauseError) no function clause matching in Parser.parse_lock/1
The following arguments were given to Parser.parse_lock/1:
# 1
{:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "0db1ee8d1547ab4877c5b5dffc6604ef9454e189928d5ba8967d4a58a801f161"}
parse_deps.exs:69: Parser.parse_lock/1
parse_deps.exs:19: Parser.build_dependency/2
(elixir) lib/enum.ex:1336: Enum."-map/2-lists^map/1-0-"/2
parse_deps.exs:101: (file)
{"error":""}
EDIT: I'm using version 1.6
Hi! I'm getting the following error after installing your lib:
== Compilation error in file lib/shopify/graphql/limiter/producer.ex ==
** (CompileError) lib/shopify/graphql/limiter/producer.ex:2: module GenStage is not loaded and could not be found
(elixir 1.11.0) expanding macro: Kernel.use/1
lib/shopify/graphql/limiter/producer.ex:2: Shopify.GraphQL.Limiter.Producer (module)
adding gen_stage to my dependency list solved it
{:gen_stage, "~> 1.0.0"},
It seems that GenStage is not part of Elixir environment as default and also not part of a newly created Phoenix project.
I'm doing a PR for fixing that :)
Hi there! ๐
Thanks for creating this library! It looks to be very helpful as a means to interface with Shopify.
I'm in the early stage of trying to figure out the approach for a new Shopify app and it would be great to depend on version 2.0 instead of version 1.x but I wanted to try to get a sense of how far off 2.0 is (given that it's already on rc versions).
I want to start off by saying thank you for open sourcing this library. It's been really helpful :)
We're encountering an issue in production with 2.0-rc3 where the response body has already been decoded and Jason is raising an exception. I've included the stack trace below. I can't reproduce it in development, but it pops up pretty regularly in production. I haven't been able to figure out why the response body has already been decoded.
I submitted a PR that bandaids the issue, but doesn't get to the root cause. I'd be happy to update my PR if you have some ideas on what the root cause might be.
* (ArgumentError) argument error
:erlang.iolist_to_binary(%{"data" => %{"product" => %{"id" => "gid://shopify/Product/PRODUCT_ID", "totalVariants" => 30}}, "extensions" => %{"cost" => %{"actualQueryCost" => 1, "requestedQueryCost" => 1, "throttleStatus" => %{"currentlyAvailable" => 999, "maximumAvailable" => 1.0e3, "restoreRate" => 50.0}}}})
(jason 1.2.2) lib/jason.ex:55: Jason.decode/2
(jason 1.2.2) lib/jason.ex:76: Jason.decode!/2
(shopify_graphql 2.0.0-rc.3) lib/shopify/graphql/response.ex:18: Shopify.GraphQL.Response.new/2
(shopify_graphql 2.0.0-rc.3) lib/shopify/graphql/request.ex:97: Shopify.GraphQL.Request.finish/2
(shopify_graphql 2.0.0-rc.3) lib/shopify/graphql/limiter/consumer.ex:20: Shopify.GraphQL.Limiter.Consumer.send/1
(elixir 1.11.2) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
(stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Function: &Shopify.GraphQL.Limiter.Consumer.send/1
Args: [%{config: %Shopify.GraphQL.Config{access_token: "*****************************", endpoint: "/graphql.json", http_client: Shopify.GraphQL.Http.Hackney, http_client_opts: [timeout: 150000, max_connections: 500, recv_timeout: 30000, ssl_options: [versions: [:"tlsv1.2"]]], http_headers: [], http_host: "myshopify.com", http_path: "/admin/api", http_port: nil, http_protocol: "https", json_codec: Jason, limiter: true, limiter_opts: [monitor: true], retry: Shopify.GraphQL.Retry.Linear, retry_opts: [max_attempts: 3], shop: "shop_name", version: "2021-01"}, limiter_opts: [monitor: true], owner: {#PID<0.4108.2>, #Reference<0.879404005.3716677635.179382>}, partition: :"Elixir.Shopify.GraphQL.Limiter.Partition:shop_name.myshopify.com", request: %Shopify.GraphQL.Request{body: "{\"query\":\"query {\\n product(id: \\\"gid://shopify/Product/PRODUCT_ID\\\") {\\n id\\n totalVariants\\n }\\n}\\n\",\"variables\":{}}", config: %Shopify.GraphQL.Config{access_token: "*****************************", endpoint: "/graphql.json", http_client: Shopify.GraphQL.Http.Hackney, http_client_opts: [timeout: 150000, max_connections: 500, recv_timeout: 30000, ssl_options: [versions: [:"tlsv1.2"]]], http_headers: [], http_host: "myshopify.com", http_path: "/admin/api", http_port: nil, http_protocol: "https", json_codec: Jason, limiter: true, limiter_opts: [monitor: true], retry: Shopify.GraphQL.Retry.Linear, retry_opts: [max_attempts: 3], shop: "shop_name", version: "2021-01"}, headers: [{"content-type", "application/json"}, {"x-shopify-access-token", "*****************************"}], method: :post, private: %{}, url: "https://shop_name.myshopify.com/admin/api/2021-01/graphql.json"}}]
Hi,
I'm trying to use your library to access Shopify to download products. I've tried setting up the rate limiting, but it isn't working for some reason. I'm not sure if I've missed something or what the deal is.
I've added the gen_state dependency to my mix.exs file:
{:gen_stage, "~> 1.0"},
I've started Shopify.GraphQL.Limiter in my supervision tree:
def start(_type, _args) do
# List all child processes to be supervised
children = [
# Start the Ecto repository
AppapiPhx.Repo,
# Start the PubSub system
{Phoenix.PubSub, name: AppapiPhx.PubSub},
# Start the endpoint when the application starts
AppapiPhxWeb.Endpoint,
# Starts a worker by calling: AppapiPhx.Worker.start_link(arg)
# {AppapiPhx.Worker, arg},
Shopify.GraphQL.Limiter
]
# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: AppapiPhx.Supervisor]
Supervisor.start_link(children, opts)
end
I've added the limiter: true option to my send:
Shopify.GraphQL.send(%{access_token: token, shop: shop, limiter: true})
I get:
GenServer.call(:"Elixir.Shopify.GraphQL.Limiter.Producer:image-and-get-it.myshopify.com", {:process,
{%Shopify.GraphQL.Operation{query: "query ($numProducts: Int!, $cursor: String){\n products(first: $numProducts, after:
$cursor) {\n pageInfo {\n hasNextPage\n }\n edges {\n cursor\n node {\n id\n title\n
productType\n vendor\n variants(first: 20) {\n pageInfo {\n hasNextPage\n }\n edges {\n
node {\n id\n weight\n title\n weightUnit\n sku\n }\n }\n }\n }\n }\n
}\n}\n", variables: %{cursor: "eyJsYXN0X2lkIjo1MTYwMDAzNzY0MzYxLCJsYXN0X3ZhbHVlIjoiNTE2MDAwMzc2NDM2MSJ9",
numProducts: 30}}, %Shopify.GraphQL.Config{access_token: "token", endpoint:
"graphql.json", headers: [], host: "myshopify.com", http_client: Shopify.GraphQL.Client.Hackney, http_client_opts: [],
json_codec: Jason, limiter: true, limiter_opts: [], path: "admin/api", port: nil, protocol: "https", retry: false, retry_opts: [],
shop: "shop", version: nil}}}, :infinity)
Any insight would be greatly appreciated!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.