GithubHelp home page GithubHelp logo

moltin / gatsby-source-moltin Goto Github PK

View Code? Open in Web Editor NEW
21.0 16.0 4.0 154 KB

๐Ÿš€ Gatsby source plugin for building Elastic Path Commerce Cloud powered eCommerce websites

Home Page: https://www.gatsbyjs.org/packages/@moltin/gatsby-source-moltin

License: MIT License

JavaScript 100.00%
moltin gatsby gatsby-plugin gatsby-source-plugin

gatsby-source-moltin's Introduction

Elastic Path Commerce Cloud gatsby-source-moltin

Stable Branch License: MIT contributions welcome follow on Twitter

๐Ÿš€ Gatsby source plugin for building Elastic Path Commerce Cloud powered eCommerce websites.

Install

yarn add @moltin/gatsby-source-moltin

How to use

// In your gatsby-config.js
plugins: [
  {
    resolve: `@moltin/gatsby-source-moltin`,
    options: {
      client_id: '...'
    },
  },
],

How to query

{
  allMoltinProduct {
    edges {
      node {
        id
        name
        description
        slug
        sku
        categories {
          id
          name
        }
      }
    }
  }
}

Terms And Conditions

  • Any changes to this project must be reviewed and approved by the repository owner. For more information about contributing, see the Contribution Guide.
  • For more information about the license, see MIT License.

gatsby-source-moltin's People

Contributors

notrab avatar renovate[bot] avatar rostyk-kanafotskyy avatar samblacklock avatar shaunmaharaj avatar spennydl avatar stuckj avatar ynnoj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gatsby-source-moltin's Issues

Issue destructuring included object if there are no main_image relationships

When destructuring the the included object from the call to get all products we need to defend against cases where none of the retrieved products have a main_image relationship. In those instances we're unable to destrcuture from an undefined object (included).

TypeError: Cannot destructure property main_images of 'undefined' or 'null'.

const {
data: products,
included: { main_images }
} = await moltin.get('products?include=main_image')

Cannot query field "allMoltinProduct" on type "Query".

I have try running

{
  allMoltinProduct {
    edges {
      node {
        id
        name
        description
        slug
        sku
        categories {
          id
          name
        }
      }
    }
  }
}

{
"errors": [
{
"message": "Cannot query field "allMoltinProduct" on type "Query".",
"locations": [
{
"line": 2,
"column": 3
}
],
"stack": [
"GraphQLError: Cannot query field "allMoltinProduct" on type "Query".",
" at Object.Field (C:\Users\User\WebstormProjects\new-gatsby-ecomm\ecommerce-gatsby-tutorial\node_modules\graphql\validation\rules\FieldsOnCorrectType.js:53:31)",
" at Object.enter (C:\Users\User\WebstormProjects\new-gatsby-ecomm\ecommerce-gatsby-tutorial\node_modules\graphql\language\visitor.js:324:29)",
" at Object.enter (C:\Users\User\WebstormProjects\new-gatsby-ecomm\ecommerce-gatsby-tutorial\node_modules\graphql\language\visitor.js:375:25)",
" at visit (C:\Users\User\WebstormProjects\new-gatsby-ecomm\ecommerce-gatsby-tutorial\node_modules\graphql\language\visitor.js:242:26)",
" at validate (C:\Users\User\WebstormProjects\new-gatsby-ecomm\ecommerce-gatsby-tutorial\node_modules\graphql\validation\validate.js:54:22)",
" at C:\Users\User\WebstormProjects\new-gatsby-ecomm\ecommerce-gatsby-tutorial\node_modules\express-graphql\dist\index.js:154:52",
" at process._tickCallback (internal/process/next_tick.js:68:7)"
]
}
]
}

node -v
v10.16.0

windows 10

added right client_id in gatsby-config.js

{
      resolve: `@moltin/gatsby-source-moltin`,
      options: {
        client_id: 'cliend_id',
      },
    },

Cannot destructure property next of 'undefined'

If I use the latest version (1.6.0) my graphql query fails with the following errors:

gatsby-source-moltin: ERROR TypeError: Cannot destructure property next of 'undefined' or 'null'. at getPaginatedResource (/Users/user/dev/project/node_modules/@moltin/gatsby-source-moltin/gatsby-node.js:187:11)

Downgrading 1.4.1 made it work.
I'm running this query:
allProducts: allMoltinProduct { edges { node { id slug sku } } }

TypeError: Cannot read property 'href' of undefined

Hello Guys
I am trying to run the GatsBy build but getting below error. Any help is highly appreciated

gatsby build "debug"

success open and validate gatsby-configs - 0.023 s
success load plugins - 0.563 s
success onPreInit - 0.002 s
success delete html and css files from previous builds - 0.004 s
success initialize cache - 0.037 s
success copy gatsby files - 0.045 s
success onPreBootstrap - 0.007 s
(node:24004) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated

ERROR #11321 PLUGIN

"@moltin/gatsby-source-moltin" threw an error while running the onCreateNode lifecycle:

Cannot read property 'href' of undefined

TypeError: Cannot read property 'href' of undefined

  • gatsby-node.js:346
    [gatsby-demo-store]/[@moltin]/gatsby-source-moltin/gatsby-node.js:346:57

  • Array.filter

  • gatsby-node.js:345 getFileNodes
    [gatsby-demo-store]/[@moltin]/gatsby-source-moltin/gatsby-node.js:345:33

  • gatsby-node.js:373 Object.exports.onCreateNode
    [gatsby-demo-store]/[@moltin]/gatsby-source-moltin/gatsby-node.js:373:32

  • task_queues.js:97 processTicksAndRejections
    internal/process/task_queues.js:97:5

โ ฆ source and transform nodes
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ build: gatsby build "debug"
npm ERR! Exit status 1
npm ERR!

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): update dependency husky to v4.3.8
  • chore(deps): update dependency lint-staged to v10.5.4
  • chore(deps): update dependency prettier to v2.6.2
  • chore(deps): update dependency husky to v7
  • chore(deps): update dependency lint-staged to v12
  • chore(deps): update dependency semantic-release to v19
  • fix(deps): update dependency gatsby-source-filesystem to v4

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.


  • Check this box to trigger a request for Renovate to run again on this repository

What if products more than 100?

I have 5000+ products in Moltin and how can I fetch all of this to generate pages via gatsby-node.js?

Tried:

  • allMoltinProduct(skip: 100)
  • allMoltinProduct(limit: 6000)

it's doesn't work, I always see 100 products

TypeError: Cannot destructure property `link` of 'undefined' or 'null'.

Package version: 1.3.1

It works in develop, throws error when trying to build.

error UNHANDLED REJECTION


  TypeError: Cannot destructure property `link` of 'undefined' or 'null'.
  
  - gatsby-node.js:30 processProduct
    [gatsby-starter-e-commerce]/[@moltin]/gatsby-source-moltin/gatsby-node.js:30:25
  
  - gatsby-node.js:166 products.forEach
    [gatsby-starter-e-commerce]/[@moltin]/gatsby-source-moltin/gatsby-node.js:166:15
  
  - Array.forEach
  
  - gatsby-node.js:164 createProducts
    [gatsby-starter-e-commerce]/[@moltin]/gatsby-source-moltin/gatsby-node.js:164:14
  
  - gatsby-node.js:177 Object.exports.sourceNodes
    [gatsby-starter-e-commerce]/[@moltin]/gatsby-source-moltin/gatsby-node.js:177:9
  
  - next_tick.js:81 processTicksAndRejections
    internal/process/next_tick.js:81:5

Compile fails

A new error cropped up for me while compiling:

error UNHANDLED REJECTION


  TypeError: Cannot destructure property `link` of 'undefined' or 'null'.
  
  - gatsby-node.js:37 processProduct
    [kooi-dev-store]/[@moltin]/gatsby-source-moltin/gatsby-node.js:37:25
  
  - gatsby-node.js:210 products.forEach
    [kooi-dev-store]/[@moltin]/gatsby-source-moltin/gatsby-node.js:210:15
  
  - Array.forEach
  
  - gatsby-node.js:208 createProducts
    [kooi-dev-store]/[@moltin]/gatsby-source-moltin/gatsby-node.js:208:14
  
  - gatsby-node.js:222 Object.exports.sourceNodes
    [kooi-dev-store]/[@moltin]/gatsby-source-moltin/gatsby-node.js:222:9
  
  - next_tick.js:81 processTicksAndRejections
    internal/process/next_tick.js:81:5

In your gatsby-node.js where you destructure the main-image href:

const {
          link: { href }
        } = main_images.find(
          main_image =>
            main_image.id === product.relationships.main_image.data.id
        )

Any idea why this is happening? Is there an issue with Moltin at the moment, not providing links to my images? Or does this happen because I might have posted images to Moltin without "public: true"?

Either way though, the plugin fails compilation due to it

Stock levels are incorrect

The GraphQL query for meta-stock gives incorrect data. It always reports "level": 0 and "availability": "out-stock" regardless of the values on Moltin

Add product variations

Product variations are a popular request for the source plugin. Below is an example of how we could query the product variations.

query($id: String!) {
  product: moltinProduct(id: { eq: $id }) {
    variants {
      id
      name
      options {
        id
        name
        description
      }
    }
  }
}

The above query would be a wrapper around the meta.variations. Not sure if this is overkill?

Currency format is wrong

I've changed the currency format on Moltin. The change is visible when I make curl request, but on GraphiQL the changes are not visible. I can only assume the gatsby-source-moltin library is at fault?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.