Yaroslav
Yaroslav

Reputation: 1

Shopify Error: Field 'customerByIdentifier' doesn't exist on type 'QueryRoot'

export const loader = async ({ request }: LoaderFunctionArgs) => {
  await authenticate.admin(request);

  const admin = await authenticate.admin(request);

  const email = "[email protected]";

  const response = await admin.admin.graphql(
    `#graphql
      query GetCustomers($query: String!) {
        customerByIdentifier(identifier: {emailAddress: $query}) {
          id
        }
      }
    `,
    {
      variables: { query: email }
    }
  );

  const data = await response.json();

  console.log(">>>>> data", data, "<<<<<<");

  return json({ apiKey: process.env.SHOPIFY_API_KEY || "" });
};

enter image description here

I have a big problem. Recently it became possible via Shopify's admin API to make a customerByIdentifier request that looks like this

{
  customerByIdentifier(identifier) {
    # Customer fields
  }
}

As you can see from the above code, I am querying via graphQl and all I get on Frontend is ‘Error: Field “customerByIdentifier” doesn't exist on type “QueryRoot”’

But when I test this query in the Shopify GraphQl App it gives me the user on this query correctly, here is the query I make through apk

{
  customerByIdentifier(identifier: {emailAddress: ‘[email protected]’}) {
    id
  }
}

Help me understand what I'm doing wrong ?

Upvotes: 0

Views: 33

Answers (0)

Related Questions