Skip to content

Instantly share code, notes, and snippets.

View jgoux's full-sized avatar
I'm the fastest meme alive

Julien Goux jgoux

I'm the fastest meme alive
View GitHub Profile
@jgoux
jgoux / eslint.config.js
Created September 12, 2023 16:32
Strict and sensible ESLint, Prettier and TypeScript configuration
import typescriptPlugin from "@typescript-eslint/eslint-plugin";
import typescriptParser from "@typescript-eslint/parser";
import prettierConfig from "eslint-config-prettier";
import importPlugin from "eslint-plugin-import";
import nodeImportPlugin from "eslint-plugin-node-import";
import prettierPlugin from "eslint-plugin-prettier";
import perfectionistPlugin from 'eslint-plugin-perfectionist';
import unusedImportsPlugin from "eslint-plugin-unused-imports";
import globals from "globals";
@jgoux
jgoux / exampleUsage.ts
Created March 17, 2021 13:08 — forked from jasonkuhrt/exampleUsage.ts
Abstraction for defining result fields in Nexus
/**
* This does not show surrounding code like referenced types.
*/
resultMutationField('inviteUserToProject', {
input(t) {
t.nonNull.id('userHandle')
t.nonNull.id('projectId')
t.nonNull.field('role', {
type: 'ProjectRole',
@jgoux
jgoux / index.md
Last active February 23, 2020 10:00
Modern web app stack
async function withAuthenticatedPgClient(
{ pgPool, needTransaction, sqlSettingsQuery },
fn
) {
const provideClient = async pgClient => {
if (sqlSettingsQuery) {
await pgClient.query(sqlSettingsQuery)
}
return await fn(pgClient)
}
import { gql } from "apollo-server-koa"
export let typeDefs = gql`
type Action {
id: ID!
libelle: String!
active: Boolean!
}
`
@jgoux
jgoux / YOLO.md
Last active January 16, 2019 17:54
Outside-in type directed GraphQL

In the context of a fullstack web application here is the workflow I'd like to have for a great DX.

1. Client-side

1.1 Start from the UI, build it screen by screen in isolation with something like storybook/react-cosmos.

1.2 For a screen, write your data needs in term of graphql queries, mutations and/or subscriptions.

1.3 If you use a strongly typed language (like Purescript or Reason) it should be able to fail at compile time because schema's types are missing. For JS, the tools (cli, vscode extension...) should be able to point the undefined types, queries, mutations and subscriptions (if you use SDL in gql tag for example).

@jgoux
jgoux / README.md
Last active January 16, 2019 15:26
Proxy issue with Gatsby

During development, I want to be able to proxy my GraphQL queries to my own GraphQL server at http://localhost:3000/graphql

I configured Gatsby like this :

module.exports = {
  proxy: {
    prefix: '/graphql',
    url: 'http://localhost:3000'
  }
}
@jgoux
jgoux / Autocomplete.js
Last active September 11, 2023 15:59
Material UI Autocomplete
import React, { Component } from 'react'
import { findDOMNode } from 'react-dom'
import R from 'ramda'
import injectSheet from 'react-jss'
import Tether from 'react-tether'
import { List } from 'react-virtualized'
const defaultState = {
input: {
searchText: ''
@jgoux
jgoux / App.js
Last active March 28, 2017 10:10
CSS Grid Layout + React, version 2! (https://www.webpackbin.com/bins/-KgGJxladDSzvMZkxAT8)
import React from 'react'
import styled, { injectGlobal, css } from 'styled-components'
import Grid from './Grid'
injectGlobal`
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
@jgoux
jgoux / database.js
Last active March 13, 2017 14:42
Database service
import R from 'ramda';
import knex from 'knex';
export const connect = knex;
export const disconnect = async client => {
return await client.destroy();
};
export const withClient = R.curry(async (config, cb) => {