Skip to content

Instantly share code, notes, and snippets.

View JCMais's full-sized avatar
🚀
Being Happy

Jonathan Cardoso JCMais

🚀
Being Happy
View GitHub Profile

This rule lints for non-colocated fragment spreads within queries or fragments. In other words, situations where a fragment is spread in module A, but the module (B) that defines that fragment is not imported by module A. It does not lint subscriptions or mutations. This catches:

  • The anti-pattern of spreading a fragment in a parent module, then passing that data down to a child module, or jamming it all in context. This defeats the purpose of Relay. From the Relay docs – "[Relay] allows components to specify what data they need and the Relay framework provides the data. This makes the data needs of inner components opaque and allows composition of those needs."
  • Instances where fragment spreads are unused, which results in overfetching. In addition to consuming more gCPU, it can also sometimes cause SEVs: D19057571

When the fragment is unused

The easiest way to tell if a fragment is unused is to remove the line containing the lint error, run js1 rebuild relay, the

@sibelius
sibelius / learning-path-web3.md
Last active June 18, 2024 17:52
Learning Path Web3
  • learn blockchain concepts
  • learn ethereum
  • learn how to use metamask
  • learn how to use hardhat (https://hardhat.org/)
  • learn how to deploy and interact with a smart contract
  • learn common smart contract standards like ERC20 (token), ERC721 (nft), ERC1155 (opensea)
  • learn ipfs
  • learn how to read blockchain explorers like https://etherscan.io/
  • learn how to use web3 and etherjs
  • learn solidity
@sibelius
sibelius / useSWReg.tsx
Created May 26, 2020 11:57
use Service Worker Registration hook
import firebase from 'firebase/app';
import 'firebase/messaging';
import { useEffect, useRef } from 'react';
import config from '../config';
import firebaseConfig from './firebaseConfig';
import { PushTokenAddMutation } from './__generated__/PushTokenAddMutation.graphql';
import { PushTokenAdd, USER_PUSHENDPOINT_TYPE } from './PushTokenAddMutation';
@sibelius
sibelius / applyMiddleware.ts
Created April 7, 2020 11:55
trace resolver to generate span for each GraphQL resolver
import { addMiddleware } from 'graphql-add-middleware';
addMiddleware(schema, traceResolveMiddleware);
@JohnAlbin
JohnAlbin / _README.md
Last active March 18, 2024 09:25 — forked from clarkdave/createPages.ts
TypeScript + Gatsby config and node API

README

  1. When Gatsby starts up, it will read gatsby-config.js first.
  2. As you can see below, we use that file to require('ts-node').register() which registers a TypeScript evaluator that will be used when Gatsby reads all other API Javascript files. In other words, we only need to do this once in our entire codebase and not in other Gatsby files like gatsby-node.js.
  3. Our gatsby-config.js re-exports all the exported variables available in gatsby-config.ts.
@sibelius
sibelius / safeGoBack.tsx
Created July 19, 2019 15:21
Safe goBack helper to avoid leaving the site
export const safeGoBack = (
history: History,
alternativeRoute: string,
) => {
if (history.length > 2) {
history.goBack();
return;
}
history.push(alternativeRoute);
@lucianomlima
lucianomlima / adb_connect.sh
Created June 5, 2019 17:57
Connect to Android devices with ADB through wi-fi
function adb_connect {
# PORT used to connect. Default: 5555
PORT=${1:-5555}
# IP address from current device connected
IP_ADDRESS=`adb shell ip route | awk '{print $9}'`
echo "ADB connect to $IP_ADDRESS on port $PORT"
# Change connection from usb to tcpip using $PORT
@lucasbento
lucasbento / reload.sh
Created May 10, 2019 09:15
Reload react-native on Android from CLI
adb shell input keyevent 82 && adb shell input keyevent 19 && adb shell input keyevent 23
@sibelius
sibelius / Sample.tsx
Created February 27, 2019 15:47
useRelayPagination to be used with React Native Flatlist
const {
isFetchingEnd,
isFetchingTop,
onRefresh,
onEndReached,
} = useRelayPagination(relay, users);
const isRefreshing = isFetchingEnd || isFetchingTop;
<FlatList
@JCMais
JCMais / k8s-cluster.json
Created January 4, 2019 13:01
Grafana dashboards from kubernetes app but using prometheus metrics instead of the datasource from the plugin
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",