Skip to content

Whatever happened to the nice old GQL client? #1083

@resistorsoftware

Description

@resistorsoftware

Old code was nice, for example, in a background job.

Get the shop_domain in a perform_later argument, and use it to find the shop and then use the Rails App convenience method with_shopify_session:

shop.with_shopify_session 
   query = Shopify::Queries::GetProductByHandle
   result = ShopifyAPI::GraphQL.client.query(query, variables: {handle: "memememe})
end

So those halcyon days are over? Now with the improved? API we have this new call structure where we have to initiate a session manually, and then use the client we get using that session to get data and run queries.

Long-winded new approach:

session = ShopifyAPI::Auth::Session.new(
  shop: shop.shopify_domain,
  access_token: shop.shopify_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
 session: session
)
query = Shopify::Queries::GET_SHOP_NAME
results = client.query(query: query)

So as a Feature Request, can we get back our old convenience of issuing GQL queries in the with_shopify_session method initiated on the shop? Or at least, can you point me to a shortcut for the long-winded approach?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions