app.get('/', (req, res) => {
  const shop =  process.env.SHOP_URL; // Replace with your Shopify store name

  if (!accessToken) {
    return res.status(403).send('Access token not available.');
  }

  const graphqlEndpoint = `https://${shop}/admin/api/2021-10/graphql.json`; // Update the API version if needed
  const graphqlQuery = `
  mutation {
    productUpdate(input: {id: "gid://shopify/Product/8141623329016", title: "TEST NAME 2025"}) {
      product {
        id
      }
    }
  }
  
  
  `;

  const graphqlRequest = {
    uri: graphqlEndpoint,
    method: 'POST',
    headers: {
      'X-Shopify-Access-Token': accessToken,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ query: graphqlQuery }),
  };

  request(graphqlRequest, (error, response, body) => {
    if (!error && response.statusCode === 200) {
      const responseData = JSON.parse(body);
      console.log('GraphQL Response:', responseData.data);
      res.send('Data from Shopify: ' + JSON.stringify(responseData.data)); // Send the data to the client
    } else {
      console.error('Error making GraphQL request:', error);
      res.status(500).send('Error fetching data from Shopify');
    }
  });
});