I have such user that create some order and I attach user some permission like Order managment in saleor admin panel. I logged in app in localhost:3000 using such user. Here is my response from CurrentCustomer.
{
"data": {
"me": {
"id": "VXNlcjoyMDg0NTEwNTU1",
"permissionGroups": [
{
"id": "R3JvdXA6MTM=",
"name": "Orders management",
"userCanManage": true
}
],
"userPermissions": [
{
"code": "HANDLE_CHECKOUTS",
"name": "Handle checkouts"
},
{
"code": "HANDLE_PAYMENTS",
"name": "Handle payments"
},
{
"code": "HANDLE_TAXES",
"name": "Handle taxes"
},
{
"code": "IMPERSONATE_USER",
"name": "Impersonate user."
},
{
"code": "MANAGE_APPS",
"name": "Manage apps"
},
{
"code": "MANAGE_CHANNELS",
"name": "Manage channels."
},
{
"code": "MANAGE_CHECKOUTS",
"name": "Manage checkouts"
},
{
"code": "MANAGE_DISCOUNTS",
"name": "Manage sales and vouchers."
},
{
"code": "MANAGE_GIFT_CARD",
"name": "Manage gift cards."
},
{
"code": "MANAGE_MENUS",
"name": "Manage navigation."
},
{
"code": "MANAGE_OBSERVABILITY",
"name": "Manage observability"
},
{
"code": "MANAGE_ORDERS",
"name": "Manage orders."
},
{
"code": "MANAGE_ORDERS_IMPORT",
"name": "Manage orders import."
},
{
"code": "MANAGE_PAGES",
"name": "Manage pages."
},
{
"code": "MANAGE_PAGE_TYPES_AND_ATTRIBUTES",
"name": "Manage page types and attributes."
},
{
"code": "MANAGE_PLUGINS",
"name": "Manage plugins"
},
{
"code": "MANAGE_PRODUCTS",
"name": "Manage products."
},
{
"code": "MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES",
"name": "Manage product types and attributes."
},
{
"code": "MANAGE_SETTINGS",
"name": "Manage settings."
},
{
"code": "MANAGE_SHIPPING",
"name": "Manage shipping."
},
{
"code": "MANAGE_STAFF",
"name": "Manage staff."
},
{
"code": "MANAGE_TAXES",
"name": "Manage taxes"
},
{
"code": "MANAGE_TRANSLATIONS",
"name": "Manage translations."
},
{
"code": "MANAGE_USERS",
"name": "Manage customers."
}
],
"defaultShippingAddress": null,
"email": "[email protected]",
"firstName": "Artur",
"lastName": "Demenskiy",
"dateJoined": "2024-02-01T08:26:56.144104+00:00"
}
},
"extensions": {
"cost": {
"requestedQueryCost": 3,
"maximumAvailable": 50000
}
}
}
I run query that get all orders, but I have some problems. Why is it ? I already gave him permission.
here is my handler
import type { OperationContext } from '@vercel/commerce/api/operations'
import { GraphQLFetcherResult } from '@vercel/commerce/api'
import type { Provider, SaleorConfig } from '..'
import * as Query from '../../utils/queries'
type ReturnType = {
orders: any[]
}
export default function getAllOrdersOperation({
commerce,
}: OperationContext<Provider>) {
async function getAllOrders({
query = Query.OrderMany,
variables = {
first: 10,
filter: {
customer: 'VXNlcjoyMDg0NTEwNTU1',
},
},
config,
}: {
query?: string
variables?: any
config?: Partial<SaleorConfig>
preview?: boolean
} = {}): Promise<ReturnType> {
const { fetch, locale, locales = ['en-US'] } = commerce.getConfig(config)
console.log({ variables, locale })
try {
const { data }: GraphQLFetcherResult = await fetch(
query,
{ variables },
{
...(locale && {
'Accept-Language': locale,
}),
}
)
console.log('hello', { data })
const orders = data?.orders?.edges?.map(({ node: order }: any) => order)
return { orders }
} catch (err) {
console.error('Error fetching orders', err)
return { orders: [] }
}
}
return getAllOrders
}
and here is my graphQl query
import * as fragment from '../fragments'
export const OrderMany = /* GraphQL */ `
query OrderMany($first: Int = 10, $filter: OrderFilterInput) {
orders(first: $first, filter: $filter) {
...OrderConnection
}
}
${fragment.OrderConnection}
`
export const OrderConnection = /* GraphQL */ `
fragment OrderConnection on OrderCountableConnection {
pageInfo {
hasNextPage
hasPreviousPage
}
edges {
node {
id
number
status
isShippingRequired
canFinalize
created
customerNote
paymentStatus
userEmail
isPaid
}
}
}
`
I drop already customer id or email but it doesn`t work
variables = {
first: 10,
filter: {
customer: 'VXNlcjoyMDg0NTEwNTU1',
},
},