A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Is there a way to get the logged in customer from any store?
Yes, if you have Generated the token while installing the Custom app.
then you can get all the details of any store.
Here is a link,
https://shopify.dev/api/admin-rest/2022-04/resources/customer#top
What I'm trying to do is use the id field of the customer who has logged into my Shopify store to fetch data from my server. Any idea how?
Ideally, you would use a customerAccessToken and replace the ID with that. Customer mutations allow for either ID or customerAccessToken. Here is an example query:
const queryCust = `{
customer(customerAccessToken: "${token}"){
id
firstName
lastName
defaultAddress{
address1
}
}
}
`
Thanks for replying. Where do I get the token?
You need to generate it at user login. It'll look something like this:
const query = `
mutation customerAccessTokenCreate($input: CustomerAccessTokenCreateInput!) {
customerAccessTokenCreate(input: $input) {
customerAccessToken {
accessToken,
expiresAt
}
customerUserErrors {
field
message
code
}
}
}
`
const variables = {
"input": {
"email": email,
"password": password,
}
}