Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow customizing fields queried #7

Open
mglaman opened this issue Dec 19, 2019 · 0 comments
Open

Allow customizing fields queried #7

mglaman opened this issue Dec 19, 2019 · 0 comments

Comments

@mglaman
Copy link
Contributor

mglaman commented Dec 19, 2019

I'll help expand on this, but here's what I'm currently doing.

My config passes this to the theme plugin

      productFields:`id drupal_id title path { alias } body { processed }`,
      variationFields:`id drupal_id sku title price { number currency_code formatted } relationships { field_images { localFile { absolutePath childImageSharp { fluid(maxWidth: 555, maxHeight: 570) { base64 src aspectRatio src srcSet } } }}}`,

in my createPages

  let {productFields, variationFields} = pluginOptions;
  productFields = productFields || `id title path { alias } body { processed }`;
  variationFields = variationFields || `id sku title price { number currency_code formatted }`;

And then in the allBlahTypes

    if (nodeFields) {
      const nodes = await graphql(`{
              allCommerceProduct${productTypeNodeName} {
                nodes {
                  ${productFields}
                  relationships {
                    variations {
                      ${variationFields}
                    }
                  }
                }
              }
            }`);

I'll try to pop a PR based on this to expand the functionality with sourcing nodes here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant