shopify-api-js icon indicating copy to clipboard operation
shopify-api-js copied to clipboard

How to get the Shop session into database graphql schema operation

Open Sky-bits opened this issue 3 years ago • 0 comments

Issue summary

Shopify package version "@shopify/shopify-api": "^5.0.1",

how i can access const session = Shopify.Utils.loadCurrentSession(req, res); const client = new Shopify.Clients.Graphql(session.shop, session.accessToken);

i am access the shop url from args


 const session = Shopify.Utils.loadOfflineSession("offline_"+args.shop);
 const client = new Shopify.Clients.Graphql(session.shop, session.accessToken);

Error getting

    "message": "Missing access token when creating GraphQL client",
    "locations": [
        {
            "line": 2,
            "column": 3
        }
    ]

}

with graph QL operation

my app back-end runing on the node express

express with graph QL

i want to do some shopify graqhql into my mutation operation

Expected behavior

What do you think should happen?

i can access the session into Graph QL operation

Actual behavior

node express Graph QL operation can access the session Shopify.Utils.loadCurrentSession

What actually happens?

i want to do some graph QL operation in withouth node ( req, res )

simple rest api i can access the Req and res object for graphql i can't

Tip: include an error message (in a <details></details> tag) if your issue is related to an error

Steps to reproduce the problem

  1. create any graph QL mutation on server side
  2. try to access the const session = Shopify.Utils.loadCurrentSession(req, res); const client = new Shopify.Clients.Graphql(session.shop, session.accessToken); 3 . getting the Error `const session = Shopify.Utils.loadCurrentSession(req, res); ^

ReferenceError: req is not defined `

Reduced test case

The best way to get your bug fixed is to provide a reduced test case.


Checklist

  • [ ] I have described this issue in a way that is actionable (if possible)

Sky-bits avatar Sep 14 '22 12:09 Sky-bits