Git Product home page Git Product logo

sane-shopify's Introduction

Sane Shopify

All Contributors

🚨 Heads up! This project is no longer in active development. See the official Sanity Connect for Shopify plugin instead! 🚨

All minor version changes (0.X.0) are likely to have breaking changes. If you are updating and have issues, see the alpha changelog below.

See this issue for the 1.0 roadmap.

This repo consists of several packages that connect Sanity and the Shopify Storefront API.

  • @sane-shopify/sanity-plugin: A plugin for Sanity that syncs product & collection data from Shopify to Sanity
  • @sane-shopify/server: Webhooks for updating Sanity data when it changes in Shopify. This includes a single server as well as individual Lamdbas that can be used with AWS and Netlify.
  • @sane-shopify/sync-utils: Utilities that are used across the packages
  • @sane-shopify/types: Types that are used across packages.

Curious? πŸ€”

If you want to be notified of updates, leave a comment in this issue.

Contributing

All contributions are welcome! Please open issues for any ideas for what you'd like this package to do. If you want to contribute to the project, see the Contributing docs.

What this project is

Sane Shopify was built after working around the limitations of the Shopify product & collection editor. Shopify has great e-commerce administration capabilities, but as a CMS, it's far behind solutions such as Sanity in terms of customization. Adding content beyond Shopify's defaults requires working with metafields, through 3rd-party apps or plugins. For example:

  • Adding additional blocks of text content to a collection or product
  • Adding a 'lookbook' gallery to a collection
  • Specifying related products for a product page

This project aims to solve these problems by using Sanity to extend Shopify's Products and Collections. It does this by:

  • Automatically syncing Shopify data to Sanity
  • Providing a single API endpoint for both Shopify & Sanity data

This project does not:

  • Sync data to Shopify. Products and Collections will still need to be created in Shopify. Shopify should still be used for editing variants, prices, inventory, the configuration of Collections, and other "product catalogue" management.
  • Add any e-commerce management to Sanity, such as tracking inventory, sales reports, customer management, and so on.
  • Sync additional Shopify information such as Pages, Blogs, or menus.

Caveats

  • You will need to implement your own frontend, from scratch. This will not work with Shopify's themes & liquid templates.
  • Many apps from the Shopify App store provide functionality to the frontend of websites by manipulating the liquid templates - these apps will not work. Other apps that enhance the admin dashboard will be unaffected.
  • Shopify's built-in product analytics will not work.

Installation & Setup

New setup starting with v0.11.0

In your Sanity installation, install the plugin: yarn add @sane-shopify/sanity-plugin. Once installed, add @sane-shopify/sanity-plugin to the list of plugins in sanity.json.

Add the Product and Collection documents to your schema:

  • Import the saneShopify function
  • (optional) Pass in a configuration object to extend the fields for the different object & document types
// schema.js

import { saneShopify } from '@sane-shopify/sanity-plugin'

const saneShopifyConfig = {
  ... // optional. see "configuration" below
}

const saneShopifyTypes = saneShopify(saneShopifyConfig)

export default createSchema({
  name: 'default',
  types: schemaTypes.concat([
    ...saneShopifyTypes,
  ])
})

Webhooks

Version 0.11.0 introduces webhooks to keep your Sanity data in sync.

For convenience, there are "pre-packaged" webhooks set up for Mirco JS (if you use Next.js) or Lambdas (for AWS, Netlify).

See the @sane-shopfiy/server README for instructions on setting this up.

Usage

Sane-shopify fetches your product and collection data from Shopify's Storefront API, and stores up-to-date copies of this information within Sanity. This means you can query your Sanity endpoint directly for all of the data you need to display products and collections.

Collection & Product Documents

This plugin will add two document types to your schema: shopifyCollection and shopifyProduct.

shopifyCollection

The Collection document has:

  • the read-only fields, sourced from shopify: title, handle, and shopifyId
  • a read-only products field with an array of references to the shopifyProduct documents for the products in the collection.
  • a read-only sourceData field which contains the data used to sync this document. This includes fields like image, description, tags, and so on.

shopifyProduct

The Product document has:

  • the read-only fields, sourced from shopify: title, handle, and shopifyId
  • a read-only collections field with an array of references to the shopifyCollection documents that this product belongs to.
  • a read-only sourceData field which contains the data used to sync this document. This includes fields like images, availableForSale, variants, tags, and so on.
  • an options field, which allows for custom fields for both the option (i.e. "Color") as well as option values (i.e. "Blue", "Green"). This can be helpful for instances when you would like to add things like custom descriptions or images for a particular option.
  • a variants field, which allows for custom fields for variant. Note that Shopify creates a variant for each combination of the available options.

Extending Document and Objects

The shopifyCollection and shopifyProduct documents can be extended with custom fields or other standard Sanity configuration, such as custom previews or input components.

To set this up, create a configuration object and assign custom configuration to any of the following properties:

  • collection: Extend the collection document
  • product: Extend the product document
  • productOption: Extend the product option category. (i.e. "Color")
  • productOptionValue: Extend product option values (i.e. "Blue", "Green"). Note that this will be applied to all option values, so if your product has both a "Size" and "Color" option, the fields specified here will show up in the options of both types.
  • productVariant: Extend the product variant

Example:

{
  collection: {
    // Shopify only allows a single image on collections. Here, we can add a gallery:
    fields: [
      {
        name: 'gallery',
        title: 'Gallery',
        type: 'array',
        of: [{ type: 'image' }]
      }
    ]
  },
  product: {
    fields: [
      // Shopify's HTML description input can get messy. Let's have our users enter the descriptions using Sanity's rich text instead.
      {
        name: 'description',
        title: 'Description',
        type: 'array',
        of: [{ type: 'block' }]
      },

      // Our users won't be editing fields on product variants. Let's hide that field. This will merge the "hidden" value into the sane-shoipfy defaults:
      {
        name: 'variants',
        hidden: true
      }
    ]
  },
  productVariant: {
    // Not adding anything here!
  },
  productOption: {
    // Let's make the preview for option list items a little more informative:
    preview: {
      select: {
        name: 'name',
        values: 'values'
      },
      prepare: (fields) => {
        const { name, values } = fields
        const subtitle = values.map((v) => v.value).join(' | ')
        return {
          title: name,
          subtitle
        }
      }
    }
  },
  productOptionValue: {
    // Our "Color" options will get a custom image swatch to use on the frontend

    fields: [
      {
        name: 'swatch',
        title: 'Color Swatch',
        type: 'image'
      }
    ]
  }
}

Connecting to Shopify

Set up a new app in Shopify with permissions to access the Storefront API. You'll need the Storefront Access Token (note that this is different from the Admin API key).

After you have installed the plugin and added the schema documents, open up Sanity. Click the new πŸ› Shopify tab in the header.

Enter your Shopify storefront name and your access token in the setup pane. Once this is set up, you can click the Sync button to import your collections and products.

Setting up Shopify webhooks

See the instructions in the @sane-shopify/server Readme

Working with the Cart

This plugin does not manage orders or customer carts. You will need to use Shopify's storefront API (or another solution) to do this. But, the sanity documents will include all of the product & variant IDs you need.

Debugging

If you are experiencing issues or errors, you can get detailed logging by setting the DEBUG variable - either as an environment variable (for webhooks & server-side) or as a localStorage variable.

Browser: In your console, enter window.localStorage.debug = 'sane-shopify:*' Server: Set an environment variable in your script (if working locally), i.e. DEBUG=sane-shopify:* yarn start, or add a DEBUG environment variable to your hosting environment.

Scopes:

  • sane-shopify:fetching outputs logs for all operations fetching source data from Shopify
  • sane-shopify:patch outputs logs for all sanity-related document patching
  • sane-shopify:server outputs logs for all server (webhook) logs
  • sane-shopify:* outputs all of the above

Alpha Changelog

0.24.0 🚨 BREAKING CHANGES

Shopify is deprecating the 2020-10 GraphQL API, so some changes were made to use the latest version, 2022-10. In previous versions of the API, were were able to query for all metafields on products and variants. In the latest version, you must ask for them specifically, given their namespace and key.

To configure this plugin to fetch metafields, a new shopifyConfig property has been added to the configuration. In the Sanity studio, use the configuration pane to add these values.

0.23.3

Oops, this version was meant to be published as 0.24.0. Please use 0.23.2 or 0.24 instead

Oops, this version was meant to be published as 0.24.0. Please use 0.23.2 or 0.24.0 instead.

0.20.0

The config for @sane-shopify/server has changed. onError is now part of the main config object. Instead of createWebhooks({ config, onError }), do createWebhooks(config). See the @sane-shopify/server README

Source data now includes shopify media. Thanks @liqueflies for adding this!

0.11.0

@sane-shopify/server now exports functions that can be used to handle Shopify's webhooks.

0.10.1

The plugin now marks products that are no longer in the Shopify catalogue as archived on their corresponding sanity documents. Relationships that no longer exist in Shopify are also removed.

0.9.0

Fixes setup flow

0.8.0

This release contains several breaking changes.

New features:

  • Add fields to product options and product option values
  • Simplified initial configuration

Migrating from 0.7.x

  • Use saneShopify(yourConfig) instead of createProductDocument, createCollectionDocument, etc. See the updated documentation above.
  • Many of the internal object type names have been modified. After you re-sync, your documents will likely have many fields that need to be unset. If you would like to completely remove all shopify collections and documents from your dataset, you can use this gist

0.7.0

New features:

  • Add fields to product variants

Migrating from 0.6.x

@sane-shopify/sanity-plugin now exports one more function, createProductVariant. Use it the same as the other exports - see the example in the usage instructions above.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Joseph Thomas

πŸ“– πŸ’» ⚠️

Graham Lipsman

πŸ’»

James Homer

πŸ’»

Richard Cooke

πŸ“–

Lorenzo Girardi

πŸ’»

agonsgd

πŸ›

Synim

πŸ›

blaine oneill

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!

sane-shopify's People

Contributors

allcontributors[bot] avatar good-idea avatar homerjam avatar liqueflies avatar nrgnrg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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

sane-shopify's Issues

1.0 Roadmap

This issue is to outline some goals of and work to do for a 1.0 stable release. For specific issues, see those labeled with the 1.0 milestone. Everything described here is up for discussion - if there are features would like to see or have an interesting use case, please leave a comment below.

There are a few questions in the "moving forward" section below - please chime in if you have any thoughts!

Scope

  • The main goal of this package is to sync data to Sanity, not back to Shopify.
  • Additionally, the focus will only be on syncing products & collections, and limited to what the Storefront API can read. The primary reason for this is security: by default, Sanity datasets are public. To sync orders, customer data, and so on would make it easy for users of the package to expose sensitive business information. The dashboard would also need to store Shopify API keys in its dataset. While datasets can be set up with more fine-grained access control, this package won't directly support handling sensitive data at all. (But, there will be a way to roll your own solution, see the notes under @sane-shopify/server below)

1.0 Features

overall

  • General stability. There are a lot of potential issues between the two services, and a lot of edge cases to be found and handled.
  • Testing. So far, this package has no automated tests. As the work below is completed, test coverage needs to be improved. Most of this testing will need to mock out requests and responses from Shopify & Sanity, which is kind of a drag, and could also mean more maintenance down the line as the API of the services changes. But for e-commerce, stability is crucial, so this needs to happen to some degree.
  • Project management / roadmap. I'll either use Github Projects or a Notion document to track features, their progress, and a general roadmap.
  • Documentation. This all needs better docs! Please open an issue or PR with anything you'd like to see in this regard - the whole thing is in my head at this point, so it's hard for me to see the missing pieces.

@sane-shopify/sanity-plugin

  • Sync products & collections to sanity from the dashboard
  • Create sanity document references between products & collections that match the relationships in Shopify
  • Configure what fields you would like to sync (collections and products) #17
  • Add custom fields to product variants #33
  • Add a "sync item" button to each collection/product document #51

@sane-shopify/server

  • "ready to go" serverless functions for accepting Shopify webhooks. #31
    For 1.0, this will include:

    • Product: products/create, products/update, products/delete
    • Collection: collections/create, collections/update, collections/delete

    These functions will assume some kind of standard sync. Versions will be available for AWS Lambdas (which are also used on Netlify) and Zeit.

  • A more configurable webhook, or some boilerplate to use the sync-utils API directly to write your own webhook logic.

@sane-shopify/sync-utils
This package is the core of the project and is used within the webhooks and the Sanity plugin. Most of its use will be internal, but the API will be documented and available for more advanced usage.

  • reconfigure sync-utils internal API #39

Moving Forward

Beyond that, the project will grow more depending on the needs and interest of those using it. Please let me know what you'd like to see out of sane shopify!

@sane-shopify/sync-utils

  • Sync basic shop data in a sanity document #42

    Read-only versions of the shop policies/counties/payment settings might be useful to store (mainly to avoid duplication and API rate limits)

@sane-shopify/server

  • Shop data webhook #42

@sane-shopify/sanity-plugin

  • A better dashboard experience. Right now, it's pretty basic looking, and only gives simple syncing progress information.
    • You also can't leave the tab until the syncing is complete. This may need to wait until this issue is handled by the Sanity team.
    • What sort of information would you like to see in a dashboard?
    • A recent activity feed would be great to give peace of mind that everything is working correctly

Ideas & suggestions

nevermind, closing. Feel free to open separate issues for ideas & suggestions.

variant sourceData not showing up in GraphQL Schema

Hey guys,

So I'm trying to use the new Product Variant fields that was added and I noticed that there's no ShopifyId at the variant level, it doesn't appear to be in sanityShopifyProduct nor allSanityShopifyProduct.

The use case here is I need the variant ShopifyId in order to add the right variant to cart.

This is everything I see under sanityShopifyProduct:
image

feature: Show recent activity in Dashboard

A recent activity feed would be great to give peace of mind that everything is working correctly

sync-utils

  • add a lastSync field to all documents, and update with all creates & patches

sanity-plugin

  • Use GROQ to query the datastore for the last N updates, based on the lastSync field

set up CI & semantic-release

  • add yarn build to all package's prepare scripts
  • add git commands to CI scripts:
    git checkout master
    lerna bootstrap
    git reset --hard
    lerna publish from-package --yes
    
    • make sure this pushes the updated version & commit to github.
    • The reference below mentions that developers do a manual lerna version. Make sure that the commands above take care of the versioning, so any push to master will trigger a publish.

References:

Restructure internal API, add configuration to Sanity plugin

The plugin should accept some configuration that will affect the in-dashboard syncing tool. For instance, users may want to sync products, but not collections.

The sync-utils API should also be updated to reflect this, and offer fewer, yet more configurable functions. Probably just one function for syncing single documents, and another for syncing many.

All of the webhooks will use this API as well, so their use cases will need to be taken into account.

improve shopify pane UI

Sync

  • Show a progress bar for syncing operations
  • disable sync button during sync
  • hide sync button after sync
  • Don't show until setup is complete
  • Show progress for fetching initial documents, then both syncing document
  • Show progress bar for archiving items

Summary

  • Display summary ("3 products updated", "10 collections archived")

Activity

  • Display list of recently synced products & collections

Setup

  • Show confirmation/error after submitting key
  • add "are you sure" confirm when removing keys

General

  • just make things look better!

Sync basic shop data

Read-only versions of the shop policies/counties/payment settings might be useful to store (mainly to avoid duplication and API rate limits)

  • Create sanity document type
  • include shop info in sync
  • set up webhooks
  • determine what data to sync

@homerjam could you put together a GraphQL query for the Storefront API that would fetch the information you think would be useful here?

setup screen is displayed when there is an error connecting to the API

I discovered this after updating the URL in use from https://your-storefront-name.myshopify.com/api/graphql to /api/2020-01/graphql. According to the shopify docs, this should work, but it doesn't. Anyway, it shows the Setup screen instead of a displaying some kind of error about connecting to the API:

image

A request with a bad token will also return an error - so, we'll need to differentiate between that error and other that are just not connecting in the first place, either because the URL is somehow bad (maybe the storefront name changed, but it hasn't been updated in sanity), or the request is somehow blocked in another way.

Feature Request: Customers

I'm planning to use the Storefront API as the auth layer for a GraphQL API that wraps Sanity/Shopify API requests. I'll then store additional sensitive data for each customer in Sanity which customers will have access to if they are logged in.

In order to do this I'll need to sync customer data - initially only the ID will be strictly necessary but name/email etc would obviously be useful.

With this in mind is there a way we can make the syncing system more flexible ie. not tied to products/collections so that it can be used for variants, customers etc? For instance there appears to be some repeated code in the fetching utils.

Sanity graphql-deploy error

I'm getting the following error when running sanity graphql-deploy.
Anyone else encounter the same thing?

➜  studio git:(master) npm run graphql-deploy

> [email protected] graphql-deploy /Users/raf/code/gatsby-shopify-sanity-alpha/studio
> sanity graphql deploy --playground

βœ– Generating GraphQL schema
/Users/raf/code/gatsby-shopify-sanity-alpha/studio/node_modules/@sane-shopify/sanity-plugin/lib/index.js:1
import { createElement, Fragment, Component } from 'react';
^^^^^^
SyntaxError: Cannot use import statement outside a module
    at compileFunction (<anonymous>)

[Request] Multiple Shopify stores

Hey there β€”Β 

I'm in the situation of having multiple instances of Shopify β€”Β they're exactly the same, but ideally I'd manage the content in one place. So for products, I need to have the product id's from both stores link.

Would that be a remote possibility, even with some moderate/heavy modification?

Cheers

Issue syncing on 0.7.0

Hey @good-idea, thanks for adding in product variants!

So I got it compiling fine now, however when I try to resync my shopify products (my products on Shopify has actual variants so I'm trying to resync to see if they match up to the new variants schemas), collections will sync fully, however when it gets to syncing products it gets stuck at 0, and I see the following error in console:

image

Here's my latest schema.js:

import createSchema from 'part:@sanity/base/schema-creator'
import schemaTypes from 'all:part:@sanity/base/schema-type'

import {
  createProductDocument,
  createCollectionDocument,
  createProductVariant,
  saneShopifyObjects,
} from '@sane-shopify/sanity-plugin'

const product = createProductDocument({
  fields: [
    {
      title: 'Tags',
      name: 'tags',
      type: 'array',
      of: [{ type: 'string' }],
      options: {
        layout: 'tags',
      },
    },
  ],
})
const productVariant = createProductVariant()
const collection = createCollectionDocument()

export default createSchema({
  name: 'mySchema',
  types: schemaTypes.concat([
    ...saneShopifyObjects,
    product,
    productVariant,
    collection,
  ]),
})

Lock in API version

From https://community.shopify.com/c/API-Versioning/Cannot-access-versioned-graphql-API/m-p/641464#M128:

I am able to connect to my shop's Storefront API with the URL:

https://my-shop-name.myshopify.com/api/graphql

But not with a versioned URL, i.e.:

https://my-shop-name.myshopify.com/api/2020-01/graphql
https://my-shop-name.myshopify.com/api/2019-07graphql

I'm using my storefront token in the headers. Am I missing something obvious?

0.6.3 added 2020-01, which broke the sanity plugin. 0.6.6 removes it. But, this API version should be locked in, it changes often and some changes could be breaking. :(

Custom configuration

  • Allow users to provide a custom query for what additional data to sync from Shopify when syncing

Potential issue: both the Sanity plugin and the proxy server will need to be configured with the same options.

localFile missing from `images`

Hey Joseph,

I was trying to transform Product Images using

allSanityShopifyProduct() {
  edges {
    node {
      sourceData {
        images {
          edges {
            node {
              localFile {
                childImageSharp {
                  fluid(maxWidth: 910) {
                    ...GatsbyImageSharpFluid_withWebp
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

but looks like that's not supported. Is this something you're interested in having in the package, or are we better off adding an image field in Sanity?

I'm thinking ahead about clients having to add images twice: Once in Shopify from (needed to see the thumbnail on checkout) and then once in Sanity.

Interested to see what you think.

keep sync logs

  • keep a log of sync events in a private sanity document
  • display logs in shopify tool pane

"Connected to shopify storefront", before having actually connected

Hey there β€” giving this plugin a go again! Initial setup does look much cleaner in 0.8! Unfortunately once I get to localhost:3333/shopify, I'm hit with the "Connected to shopify storefront" screen and can't Unlink. Haven't set it up yet so it's odd that that's happening.

Any ideas on a workaround?

feature: multiple storefronts

Re: #46

  • Update plugin UI to be able to add, sync, & remove multiple storefronts.
  • Include storefront info in all synced items
  • include in sync-utils API

No License

While this project is in its, obvious, early stages, there is currently no license attached the project.

We're looking around for some solutions for an upcoming project, and while this one seems like something we'd like to contribute to, I'm hesitant to push my developers here without some project licensing information.

move testSecrets, saveSecrets, clearSecrets to sync-utils

Right now, the plugin handles all of this, but these should just be moved to the sync-utils.

This might be annoying because to create the sync utils, you need to pass in credentials. If you pass in undefined credentials, calls to any method will result in an error.
But, that should be OK, users can always use testSecrets to confirm that they are in good shape

Feature: extend product variants

In progress - working on adding product variants as an array of sub-fields to the Sanity documents, allowing you to extend on these variants. For instance, adding a separate descriptions or galleries of images.

Add connections between product/collection documents

If it's all connected in Sanity, there's no need to deal with the shopify GraphQL server at all. I wish i had thought of this sooner!

Clients will still need to use the Storefront API for adding & creating checkouts, customer login, etc. But all public Product & Collection info should be synced to their Sanity documents.

fix rollup compilation warning

@sane-shopify/sanity-plugin: (!) `this` has been rewritten to `undefined`
@sane-shopify/sanity-plugin: https://rollupjs.org/guide/en#error-this-is-undefined
@sane-shopify/sanity-plugin: src/shopifyClient.ts
@sane-shopify/sanity-plugin: 1: var _this = this;
@sane-shopify/sanity-plugin:                ^
@sane-shopify/sanity-plugin: 2: import * as tslib_1 from "tslib";
@sane-shopify/sanity-plugin: 3: var getErrorMessage = function (r) {
@sane-shopify/sanity-plugin: src/Provider/utils.ts
@sane-shopify/sanity-plugin: 1: var _this = this;
@sane-shopify/sanity-plugin:                ^
@sane-shopify/sanity-plugin: 2: import * as tslib_1 from "tslib";
@sane-shopify/sanity-plugin: 3: import { createClient } from ../shopifyClient;
@sane-shopify/sanity-plugin: created lib/index.js, lib/index.es.js in 7.3s

Hi! If you're interested in this project, leave a comment in this issue

Until this project gets off the ground, this will be my unofficial "mailing list" :) I'll make announcements here.

Please restrict comments to a quick hello to sign up so others who have commented aren't getting too many emails.

If you have any questions about or suggestions for the project, feel free to open an issue, or find me @joseph on the Sanity.io slack channel.

Error when running sanity graphql deploy

Hey Joseph,

So I tried removing and reinstalling node modules and I'm still getting this error on 0.6.3:

βœ– Generating GraphQL schema
/Users/mathew/Dev/esqido-gatsby-sanity/studio/node_modules/@sane-shopify/sanity-plugin/lib/index.js:1
import { createElement, createContext, Component, useContext, Fragment } from 'react';
^^^^^^
SyntaxError: Cannot use import statement outside a module
    at compileFunction (<anonymous>)
    at Object.<anonymous> (~/Dev/esqido-gatsby-sanity/studio/schemas/schema.js:4:1)

Here's my schema.js:

import createSchema from 'part:@sanity/base/schema-creator'
import schemaTypes from 'all:part:@sanity/base/schema-type'

import {
  createProductDocument,
  createCollectionDocument,
  saneShopifyObjects,
} from '@sane-shopify/sanity-plugin'

const product = createProductDocument({
  fields: [
    {
      title: 'Tags',
      name: 'tags',
      type: 'array',
      of: [{ type: 'string' }],
      options: {
        layout: 'tags',
      },
    },
  ],
})
const collection = createCollectionDocument()

export default createSchema({
  name: 'mySchema',
  types: schemaTypes.concat([...saneShopifyObjects, product, collection]),
})

Compile issue after installing

Hi there,

First of all thanks for putting this project together!

I'm currently working on a custom storefront and after following the instructions in the readme, I'm running into this compile error which didn't exist prior to installing this package:

Error in ./node_modules/graphql-tag/src/index.js
Module not found: Error: Can't resolve 'graphql/language/parser' in '/Users/mathew/Dev/esqido-gatsby-sanity/studio/node_modules/graphql-tag/src'
 @ ./node_modules/graphql-tag/src/index.js 1:13-47
 @ ./node_modules/@sane-shopify/sync-utils/lib/index.es.js
 @ ./node_modules/@sane-shopify/sanity-plugin/lib/index.js
 @ ./node_modules/@sane-shopify/sanity-plugin/lib (all:part:@sanity/base/tool)
 @ ./node_modules/@sanity/default-layout/lib/defaultLayoutRouter.js
 @ ./node_modules/@sanity/default-layout/lib/components/DefaultLayoutContainer.js (part:@sanity/base/root)
 @ ./node_modules/@sanity/base/lib/components/SanityRoot.js (part:@sanity/base/sanity-root)
 @ ./node_modules/@sanity/server/lib/browser/entry-dev.js
 @ multi ./node_modules/normalize.css/normalize.css ./node_modules/@sanity/server/lib/browser/entry-dev.js

Here's my schema.js:

import createSchema from 'part:@sanity/base/schema-creator'
import schemaTypes from 'all:part:@sanity/base/schema-type'

import {
  createProductDocument,
  createCollectionDocument,
  saneShopifyObjects,
} from '@sane-shopify/sanity-plugin'

const product = createProductDocument()
const collection = createCollectionDocument()

export default createSchema({
  name: 'mySchema',
  types: schemaTypes.concat([...saneShopifyObjects, product, collection]),
})

My sanity.json:

"plugins": [
    "@sanity/base",
    "@sanity/components",
    "@sanity/default-layout",
    "@sanity/default-login",
    "@sanity/dashboard",
    "@sanity/desk-tool",
    "dashboard-widget-structure-menu",
    "dashboard-widget-document-list",
    "dashboard-widget-netlify",
    "@sane-shopify/sanity-plugin"
  ],
  "parts": [
    {
      "name": "part:@sanity/base/schema",
      "path": "./schemas/schema.js"
    },
    {
      "name": "part:@sanity/desk-tool/structure",
      "path": "./deskStructure.js"
    },
    {
      "implements": "part:@sanity/dashboard/config",
      "path": "./dashboardConfig.js"
    }
  ]

Any advice would be appreciated!

Question

Hi,

I'm working on a proposal for a client project which would combine Shopify and Sanity - if it goes ahead I think it would be great to make use of sane-shopify and contribute to it.

There's a feature I was wondering about to reduce friction for the client - do you think it's possible to create products in Sanity and push these to Shopify via the Shopify Admin API?

Have you considered this and are there any technical constraints preventing it that I might not have considered?

Thanks,
James

Refactor sanity plugin

The frontend side of the sanity plugin is pretty messy, now is the time to refactor to make it more readable & use hooks.

  • set react deps to 16.8

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.