-
Notifications
You must be signed in to change notification settings - Fork 387
Documentation improvements #121
Comments
It would be nice to have examples/doc to show how to make requests using private apps |
Thanks @Wilddata! In case anyone ends up here from a search, to use private apps you should set Shopify.Context.initialize({
...
IS_PRIVATE_APP: true,
}); The clients work the same as for public / custom apps, but you don't need an access token. You could make REST requests like so for private apps: const client = new Shopify.Clients.Rest(shop);
await client.get({ ... }); We'll add some information around that to the docs as well. |
Based on #124 we may also need better documentation around webhooks 🤔 |
I think webhooks are fairly well covered since they're mentioned at the top level of the docs, though it seems a parameter table for them would also be helpful. The changes you made to the GraphQL client docs should make the purpose of the |
It would be highly appreciated to get some example for production. |
Maybe I'm just blind but I want to create |
I found the way: Btw: @paulomarg would not be helpful having some kind of serialization and deserialization of const session: Session = new Session({id: "id"});
const sessionPlainObject = session.serialize() // returns just plain js object
const session2: Session = new Session(sessionPlainObject); |
Hey folks, thanks for your comments! Here are my thoughts:
const session: Session = new Session({id: "id"});
function storeSession(session) {
MyStorage.store(JSON.stringify(session));
}
function loadSession(id) {
const json = MyStorage.load(id);
return JSON.parse(json);
} So you can just return |
Actually I had to import Session Class from dist. src/my_session_storage.ts - import { SessionStorage } from '@shopify/shopify-api';
+ import { Session } from '@shopify/shopify-api/dist/auth/session';
async function storeCallback(session: Session): Promise<boolean> { ... }
async function loadCallback(id: string): Promise<Session | Record<string, unknown> | undefined> { ... }
async function deleteCallback(id: string): Promise<boolean> { ... }
const mySessionStorage = new Shopify.Session.CustomSessionStorage(
storeCallback,
loadCallback,
deleteCallback,
); |
Thanks @kato-takaomi-ams, we should probably make that easier to use as a type. |
@paulomarg I'm so confused looking at the documentation for over 2 to 3 hours now. I cannot even do the simple task of creating a private app that connects to Shopify Admin API and runs a GraphQL query (or mutation). I don't understand the examples, and they are split up over various pages with no proper guidance on what's what. In contrast, I got it working with MONEI/Shopify-api-node in 10 minutes or so: const Shopify = require('shopify-api-node');
const shopify = new Shopify({
shopName: myShopifyDomain,
apiKey: api_key,
password: password
});
await shopify.customer
.list({ limit: 5 })
.then((customer) => console.log(customer))
.catch((err) => console.error(err));
const query = `{
shop {
name
}
}`;
await shopify
.graphql(query)
.then((result) => console.log(result))
.catch((err) => console.error(err)); How can it be so bad here? |
Overview/summary
Now that the library has been released, we noticed a couple of pain points that we can help remedy via documentation. This PR aggregates them so we can address them at once.
withSession
docs).CustomSessionStorage
in the session notes. We could show how to implement the callbacks using Redis.2.1. We may want to consider adding a few tips (and what-not-to-dos!) on using this feature to help developers choose their preferred method.
Checklist
The text was updated successfully, but these errors were encountered: