Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL Client inadequate since v10 upgrade #1210

Closed
zzooeeyy opened this issue Sep 5, 2023 · 1 comment · Fixed by #1246
Closed

GraphQL Client inadequate since v10 upgrade #1210

zzooeeyy opened this issue Sep 5, 2023 · 1 comment · Fixed by #1246
Assignees

Comments

@zzooeeyy
Copy link
Contributor

zzooeeyy commented Sep 5, 2023

Overview

graphql-client gem dependency was removed in the shopify-api-ruby v10 upgrade.

Instead of being able to access methods from objects to retrieve GraphQL response data, we return an HTTPResponse object instead, which means devs would have to retrieve data via hashes...

Before:

client = ShopifyAPI::GraphQL.client

SHOP_NAME_QUERY = client.parse <<-'GRAPHQL'
  {
    shop {
      name
    }
  }
GRAPHQL

result = client.query(SHOP_NAME_QUERY)
shop_name = result.data.shop.name

After:

client = ShopifyAPI::Clients::Graphql::Admin.new(session: session)

# make the GraphQL query string
query =<<~QUERY
  {
    shop {
      name
    }
  }
QUERY

response = client.query(query: query)
shop_name = response.body["data"]["shop"]["name"]

As you can see, this make migration and usage of the response data very difficult..
shop_name = result.data.shop.name vs
shop_name = response.body["data"]["shop"]["name"]
It's especially challenging if there are even more layers like

result.data.webhookSubscriptions.edges[0].node.id vs
response.body["data"]["webhookSubscriptions"]["edges"][0]["node"]["id"]

Expected behavior

We should add support to allow method access for GraphQL data instead of hash access to avoid this undesirable v10 migration side effect for existing apps, and improve new developer's GraphQL experience when building new apps.

Example Complaint

Agreed, it's virtually impossible to upgrade to v10 or later since the library no longer supports graphql-client, with no options to support it. This renders all existing GraphQL code not compatible. I'm not sure how Shopify engineering team can get rid (forget even deprecating) an existing core library and think it's ok.

Link to Comment

@Javierchik
Copy link

What if you use OpenStruct? It should do the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants