Giter Site home page Giter Site logo

gatsby-source-kushy's Introduction

gatsby-source-kushy

Source plugin for pulling a shop or brand's data into Gatsby from the Kushy API.

Add your shop or brand to the configuration file and Gatsby will import your profile data, menu, and all your reviews and photos into GraphQL.

Great for creating a website or landing page for a dispensary or brand.

  • Demo
  • Example site source code

Getting Started

  1. npm install --save gatsby-source-kushy
  2. Add the plugin to gatsby-config.js:
    {
      resolve: 'gatsby-source-kushy',
      options: {
        // Access the shops or brands section?
        section: 'shops',
        // The slug of your shop/brand
        slug: 'chronic-pain-relief-center',
        // This helps the source plugin use the Kushy API to find your shop
        // e.g. http://api.kushy.net/v1/<section>/?filter[slug]=<slug>
        // See Kushy API docs for more info on querying shop data
      },
    },
  1. gatsby develop
  2. Use the GraphiQL browser to query Kushy data

Querying with GraphQL

The plugin creates an endpoint called KushyPost and allKushyPost. You query KushyPost for individual posts and filter by an ID or slug. And you query allKushyPost for all imported posts.

All the parameters from the API are plugged into GraphQL, so if an API endpoint has a avatar property, you can query GraphQL for it.

Query your shop/brand

{
  allKushyPost{
    edges {
			node {
        id
        name
        featured_img
        avatar
        location {
          latitude
          longitude
          address
          state
          city
          postal_code
          country
        }
        rating
        featured
        verified
      }
    }
  }
}

Query your reviews

{
  allKushyReview {
    edges {
      node{
        id
        status
        post_id
        user_id
        rating
        useful
        dank
        funny
        review
        created_at {
					date
        }
        updated_at {
          date
        }
        includes {
					user {
            id
            name
            username
            avatar
          }
        }
      }
    }
  }
}

Query your menu

{
  allKushyMenu {
    edges {
      node{
        id
        product {
          id
          name
          slug
          categories
          avatar
          featured_img
        }
        pricing {
          pricing_type
          list_price
          sale_price
          half_gram
          one_gram
          two_grams
          eighth_ounce
          quarter_ounce
          half_ounce
          ounce
          quarter_pound
          half_pound
          pound
        }
        cannabinoids {
          thc
          cbd
          cbn
        }
      }
    }
  }
}

Query your photos

{
  allKushyPhoto {
    edges {
      node {
        id
        image
        caption
        user_id
        post_id
        featured
        created_at{
          date
          timezone
        }
        updated_at{
          date
          timezone
        }
      }
    }
  }
}

Todo

  • [✅] - Allow users to add a config for section and ID to load a specific shop/brand.
  • [✅] - Add endpoint for shop/brand menu (KushyMenu / allKushyMenu)
  • [] - Add endpoint for shop/brand photos (KushyPhotos / allKushyPhotos)
  • [✅] - Add endpoint for shop/brand reviews (KushyReviews / allKushyReviews)

Pending

  • [] - Create async function to load all pages from API, currently only loads first (see: getPages())
  • [] - Create helper function to download all loaded media into cache (see: downloadMediaFiles())

Credits

gatsby-source-kushy's People

Contributors

whoisryosuke avatar

Stargazers

 avatar  avatar  avatar

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.