Comments (3)
Anyone? I'd like to know this too.
I know where it comes from. If you edit a file in an external library saleor-sdk
, you can get additional data.
Go to /app/node_modules/@saleor/sdk/lib/fragments/categories.js
and add field you need to the exports.baseCategoryFragment
query.
Now I'd like to know how to override it correctly without direct editing of library files?
from saleor-storefront.
Editing node_modules is not a good idea. If we install the project on another workstation we will not have the changes made. If there is a solution to edit I would like to know too.
from saleor-storefront.
That's why I'd like to know how to override exports.baseategoryFragment
in the correct way (my question in bold).
categories.js
in saleor-sdk external library looks like this:
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.categoryFragment = exports.baseCategoryFragment = void 0;
const graphql_tag_1 = __importDefault(require("graphql-tag"));
exports.baseCategoryFragment = graphql_tag_1.default `
fragment BaseCategory on Category {
id
name
slug
seoDescription
seoTitle
}
`;
The same would apply for products. If I need a description
on top of default query, which includes seoDescription
only, I can edit the products.js
file:
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.productFragment = exports.productPricingFragment = exports.productVariantFragment = exports.selectedAttributeFragment = exports.baseProductFragment = void 0;
const graphql_tag_1 = __importDefault(require("graphql-tag"));
const checkout_1 = require("./checkout");
exports.baseProductFragment = graphql_tag_1.default `
fragment BaseProduct on Product {
id
name
slug
seoDescription
isAvailableForPurchase
availableForPurchase
seoTitle
thumbnail {
url
alt
}
thumbnail2x: thumbnail(size: 510) {
url
}
}
`;
When I add the description
field to exports.baseProductFragment
, I get a description data in storefront, which is great, but editing external library files is not the correct way how to do it. In the storefront code, there is only a simple line:
import { ProductList } from "@saleor/sdk/lib/queries/gqlTypes/ProductList";
I'd like to know how to override this line to get the data we need, without editing or monkey-patching the saleor-sdk
external library files.
from saleor-storefront.
Related Issues (20)
- No translation, no navigation, no menu when going to account, checkout or custom pages
- Why is the nginx server not fielding the URL requested by the browser when I go to checkout? HOT 2
- Not showing the Razorpay in saleor-storefront HOT 2
- Next.js support in Storefront
- Cannot run main branch (or Saleor Storefront 3+) at all
- Move from node-saas to sass
- Next.js Integration HOT 1
- Storefront Throwing Errors: ERROR in /app/src/views/...
- npm install fails on cwebp-bin
- PhantomJS not found on PATH when docker-compose build
- 400 (Bad Request)
- Problem with displaying the collection on the homepage HOT 1
- npm install fails "Build failed with error code: 1" HOT 1
- Saleor api returns http on media links/resources but it is set to be https uri HOT 1
- ERR_PNPM_PEER_DEP_ISSUES Unmet peer dependencies HOT 9
- Error: Cannot find module '@next/bundle-analyzer'
- npm ERR! Could not resolve dependency: HOT 1
- saleor-storefront without python2 HOT 1
- TypeError: Class extends value undefined is not a constructor or null HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from saleor-storefront.