{"version":3,"file":"graphql.mjs","sources":["../../../../../../src/server/clients/admin/graphql.ts"],"sourcesContent":["import {AdminOperations} from '@shopify/admin-api-client';\n\nimport {GraphQLClient} from '../types';\n\nimport {AdminClientOptions} from './types';\n\n// eslint-disable-next-line no-warning-comments\n// TODO: This is actually just a call through to the Shopify API client, but with a different API. We should eventually\n// move this over to the library layer. While doing that, we should also allow the apiVersion to be passed into the REST\n// client request calls.\nexport function graphqlClientFactory({\n  params,\n  handleClientError,\n  session,\n}: AdminClientOptions): GraphQLClient<AdminOperations> {\n  return async function query(operation, options) {\n    const client = new params.api.clients.Graphql({\n      session,\n      apiVersion: options?.apiVersion,\n    });\n\n    try {\n      // We convert the incoming response to a Response object to bring this client closer to the React Router client.\n      const apiResponse = await client.request(operation, {\n        variables: options?.variables,\n        retries: options?.tries ? options.tries - 1 : 0,\n        headers: options?.headers,\n        signal: options?.signal,\n      });\n\n      return new Response(JSON.stringify(apiResponse));\n    } catch (error) {\n      if (handleClientError) {\n        throw await handleClientError({error, params, session});\n      }\n\n      throw error;\n    }\n  };\n}\n"],"names":[],"mappings":"AAMA;AACA;AACA;AACA;AACM,SAAU,oBAAoB,CAAC,EACnC,MAAM,EACN,iBAAiB,EACjB,OAAO,GACY,EAAA;AACnB,IAAA,OAAO,eAAe,KAAK,CAAC,SAAS,EAAE,OAAO,EAAA;QAC5C,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC;YAC5C,OAAO;YACP,UAAU,EAAE,OAAO,EAAE,UAAU;AAChC,SAAA,CAAC;AAEF,QAAA,IAAI;;YAEF,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE;gBAClD,SAAS,EAAE,OAAO,EAAE,SAAS;AAC7B,gBAAA,OAAO,EAAE,OAAO,EAAE,KAAK,GAAG,OAAO,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC;gBAC/C,OAAO,EAAE,OAAO,EAAE,OAAO;gBACzB,MAAM,EAAE,OAAO,EAAE,MAAM;AACxB,aAAA,CAAC;YAEF,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAClD;QAAE,OAAO,KAAK,EAAE;YACd,IAAI,iBAAiB,EAAE;gBACrB,MAAM,MAAM,iBAAiB,CAAC,EAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAC,CAAC;YACzD;AAEA,YAAA,MAAM,KAAK;QACb;AACF,IAAA,CAAC;AACH;;;;"}