All Projects β†’ gil-- β†’ gatsby-plugin-apollo-client

gil-- / gatsby-plugin-apollo-client

Licence: MIT license
πŸ“‘Inject a Shopify Apollo Client into the browser.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to gatsby-plugin-apollo-client

gatsby-source-stripe
Gatsby source plugin for building websites using Stripe as a data source
Stars: ✭ 71 (+255%)
Mutual labels:  gatsby, gatsbyjs, gatsby-plugin
gatsby-plugin-prettier-build
prettify gatsby build output
Stars: ✭ 30 (+50%)
Mutual labels:  gatsby, gatsbyjs, gatsby-plugin
gatsby-plugin-disqus
πŸ’¬ A plugin for adding Disqus comments to GatsbyJS
Stars: ✭ 40 (+100%)
Mutual labels:  gatsby, gatsbyjs, gatsby-plugin
gatsby-theme-deck-n-blog
Create a deck (with mdx-deck) and a blog post from the same MDX
Stars: ✭ 17 (-15%)
Mutual labels:  gatsby, gatsbyjs, gatsby-plugin
gatsby-attila-theme-ghost
A Gatsby theme plugin for creating blogs from headless Ghost CMS.
Stars: ✭ 16 (-20%)
Mutual labels:  gatsby, gatsbyjs, gatsby-plugin
Gatsby Shopify Theme
πŸ›’ Simple theme to build a blazing simple and fast store with Gatsby and Shopify.
Stars: ✭ 95 (+375%)
Mutual labels:  gatsby, shopify, gatsbyjs
gatsby-plugin-dynamic-routes
Creating dynamic routes based on your environment and/or renaming existing routes
Stars: ✭ 14 (-30%)
Mutual labels:  gatsby, gatsbyjs, gatsby-plugin
gatsby-graphcms-example
Example of Gatsby source plugin for GraphCMS
Stars: ✭ 32 (+60%)
Mutual labels:  gatsby, gatsbyjs, gatsby-plugin
gatsby-plugin-lunr
Gatsby plugin for full text search implementation based on lunr client-side index. Supports multilanguage search.
Stars: ✭ 69 (+245%)
Mutual labels:  gatsby, gatsbyjs, gatsby-plugin
gatsby-starter-typescript
Typescript version of the default Gatsby starter. Uses Gatsby v1.x
Stars: ✭ 58 (+190%)
Mutual labels:  gatsby, gatsbyjs
gatsby-source-printful
Printful store data for your Gatsby projects
Stars: ✭ 19 (-5%)
Mutual labels:  gatsby, gatsby-plugin
gatsby-starter-highlights
Gatsby.js V2 starter template based on highlights by HTML5 UP
Stars: ✭ 15 (-25%)
Mutual labels:  gatsby, gatsbyjs
gatsby-starter-breeze
A Gatsby starter for graceful blogging in Chinese.
Stars: ✭ 44 (+120%)
Mutual labels:  gatsby, gatsbyjs
remotefrontend
Fully remote jobs for front end developers.
Stars: ✭ 18 (-10%)
Mutual labels:  gatsby, gatsbyjs
gatsby-starter-fractal
Gatsby.js V2 starter template based on Fractal by HTML5 UP
Stars: ✭ 19 (-5%)
Mutual labels:  gatsby, gatsbyjs
gatsby-starter-devto
A GatsbyJS starter template that leverages the Dev.to API
Stars: ✭ 13 (-35%)
Mutual labels:  gatsby, gatsbyjs
gatsby-plugin-asset-path
Move all of your JS and CSS build files, as well as the static folder into a subdirectory of your choice
Stars: ✭ 14 (-30%)
Mutual labels:  gatsby, gatsby-plugin
gatsby-starter-kit
A set of starters for Gatsby.js
Stars: ✭ 99 (+395%)
Mutual labels:  gatsby, gatsbyjs
gatsby-plugin-tailwindcss
Plug Tailwind CSS to your Gatsby website
Stars: ✭ 46 (+130%)
Mutual labels:  gatsby, gatsby-plugin
react-hooks-gatsby
Learn how to use React Hooks, and how they work with Gatsby. Watch the livestream:
Stars: ✭ 18 (-10%)
Mutual labels:  gatsby, gatsbyjs

gatsby-plugin-apollo-shopify

Install

npm install --save gatsby-plugin-apollo-shopify

How to use

// In your gatsby-config.js
plugins: [
  {
    resolve: `gatsby-plugin-apollo-shopify`,
    options: {
      shopName: `gatsbyjs`,
      accessToken: `48bbac10dae7225fe4e36a545d1b9b2f`,
      // Optionally set the API version you want to use. For a list of available API versions,
      // see: https://shopify.dev/concepts/about-apis/versioning/release-notes
      // Defaults to unspecified/oldest stable
      apiVersion: "2020-07",
    },
  },
]

How to Query within Gatsby

To utilize the Apollo client within your Gatsby project, import graphql-tag and react-apollo. for example:

import gql from "graphql-tag"
import { Query } from "react-apollo"

const GET_PRODUCT = gql`
  query($handle: String!) {
    shop {
      products(first:1, query: $handle) {
        edges {
          node {
            variants(first: 1) {
              edges {
                node {
                  availableForSale
                }
              }
            }
          }
        }
      }
    }
  }
`

export default ({ children, data }) => {
    const product = data.shopifyProduct

    return (
        <Query query={GET_PRODUCT} variables={{ handle: product.handle }}>
            {({ loading, error, data }) => {
                if (loading) return <div>Loading stock status...</div>
                if (error) return <div>There was an error!</div>

                return (
                <>
                    <h3>Stock Status: {data && data.shop.products && data.shop.products.edges[0].node.variants && data.shop.products.edges[0].node.variants.edges[0].node.availableForSale.toString()}</h3>
                </>
                )
            }}
        </Query>
    )
}

export const query = graphql`
    query productQuery($id: String!) {
        shopifyProduct(id: { eq: $id }) {
            handle
        }
    }
`

Credits

Most of this plugin was taken from the gatsby-plugin-apollo-client within the using-multiple-providers example site.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].