This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const stylelint = require("stylelint"); | |
const { report, ruleMessages, validateOptions } = stylelint.utils; | |
const ruleName = "w3s-stylelint-plugin/force-bem-class-selector"; | |
const messages = ruleMessages(ruleName, { | |
expected: (unfixed, fixed) => | |
`"${unfixed}" is not a valid BEM class name "${fixed}"`, | |
}); | |
module.exports = stylelint.createPlugin( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query { | |
getSlogan(language: en) { | |
slogan | |
language | |
} | |
} | |
// Returns | |
{ | |
"data": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @name Query/hybrit | |
* @method | |
* @memberof GraphQL/ExampleTemplateCollection/Query | |
* @summary query hybrit and return its slogan | |
* @param {Object} _ - unused | |
* @param {Object} args - an object of all arguments that were sent by the client | |
* @param {String} args.language - language that needs to be selected | |
* @param {Object} context - an object containing the per-request state | |
* @param {Object} info Info about the GraphQL request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @name getSlogan | |
* @method | |
* @memberof GraphQL/ExampleTemplateCollection | |
* @summary Query the slogan based on the right langauge | |
* @param {Object} context - an object containing the per-request state | |
* @param {String} language - Language that needs to be returned | |
*/ | |
export default async function getSlogan(context, languageCode) { | |
// We can find our collection by looking into context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import importAsString from "@reactioncommerce/api-utils/importAsString.js"; | |
const schema = importAsString("./schema.graphql"); | |
export default [schema]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"enum for language" | |
enum Language { | |
en | |
nl | |
de | |
esp | |
bih | |
} | |
type Slogan { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Logger from "@reactioncommerce/logger"; | |
import Random from "@reactioncommerce/random"; | |
/** | |
* @param {Object} ExampleTemplateCollection Collection that will be seeded into | |
* @param {String} translationObject Object that contains our translation | |
* @returns {undefined} | |
*/ | |
export default async function seedExampleTemplateCollection( | |
ExampleTemplateCollection, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import translationsFile from "../i18n/index.js"; | |
import seedExampleTemplate from "./seedExampleTemplate.js"; | |
/** | |
* @summary Creates a collection of translations used for our Example. | |
* @param {Object} ExampleTemplateCollection MongoDB collection that will be seeded into | |
* @returns {undefined} | |
*/ | |
export default async function seedExampleTemplateCollection(ExampleTemplateCollection) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In this file, everything that requires to be done on startup can be done | |
// This can be for example setting up a collection or seeding data | |
// Note that this fuction wil run every single time when starting the project up with docker-compose in dev mode. | |
import Logger from "@reactioncommerce/logger"; | |
import seedExampleTemplateCollection from "./util/seedExampleTemplateCollection.js" | |
/** | |
* @name startup | |
* @summary Called on startup | |
* @param {Object} context App context | |
* @returns {undefined} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import startup from "./startup.js"; | |
/** | |
* @summary Import and call this function to add this plugin to your API. | |
* @param {ReactionAPI} app ReactionAPI instance | |
* @returns {undefined} | |
*/ | |
export default async function register(app) { | |
/** | |
* Simple Ping Pong like example plugin |
NewerOlder