Skip to content

Instantly share code, notes, and snippets.

View JulienHe's full-sized avatar
🍫

Julien Henrotte JulienHe

🍫
View GitHub Profile
@JulienHe
JulienHe / snacks.json
Created August 5, 2022 00:38
Snacks schema
{
"kind": "collectionType",
"collectionName": "snacks",
"info": {
"singularName": "snack",
"pluralName": "snacks",
"displayName": "Snack",
"description": ""
},
"options": {
@JulienHe
JulienHe / index.js
Last active August 16, 2022 17:00
Resize / Rename
const rootImageFolder = './images/';
function cleanNaming(directory) {
return directory.replace(/\d{1,}\s/g, '').replaceAll(/-\s/g, '').replaceAll(/\s/g, '-').toLowerCase();
}
function renameImage(source, exportName) {
fs.rename(source, exportName, function(err) {
if ( err ) console.log('ERROR: ' + err);
log(clc.blue("Rename cover"))
@JulienHe
JulienHe / GraphQLClient.tsx
Created September 5, 2022 01:25
GraphQLClient
import { ApolloClient, InMemoryCache } from "@apollo/client";
import { SchemaLink } from "@apollo/client/link/schema";
import schema from "~/graphql/graphql-executable";
const GraphQLClient = new ApolloClient({
cache: new InMemoryCache(),
link: new SchemaLink({ schema }),
});
export default GraphQLClient;
@JulienHe
JulienHe / graphql-executable.tsx
Last active September 5, 2022 01:46
Graphql Executable
import { makeExecutableSchema } from "@graphql-tools/schema";
import typeDefs from "./typedefs";
import mockArticle from "~/graphql/mock/article";
const executableSchema = makeExecutableSchema({
typeDefs,
resolvers: {
Query: {
articles: () => mockArticle,
@JulienHe
JulienHe / typescript-typedefs.js
Created September 5, 2022 02:06
Typedefs plugin
const { printSchema } = require("graphql");
module.exports = {
plugin: (schema, documents, config) => {
const theSchema = printSchema(schema).replaceAll("`", "");
return [
"const typeDefs = /* GraphQL */ `",
theSchema,
"`;",
"export default typeDefs;",
@JulienHe
JulienHe / getArticle.graphql.tsx
Created September 5, 2022 03:35
Get Article Graphql
import { gql } from "@apollo/client";
const GET_ARTICLE = gql`
query getArticles(
$pageSize: Int = 100
$page: Int = 0
$sort: [String] = ["createdAt:desc"]
$filters: ArticleFiltersInput = {}
) {
articles(