Skip to content

Instantly share code, notes, and snippets.

View Bastiani's full-sized avatar
🏠
Working from home

Rafael de Bastiani Bastiani

🏠
Working from home
View GitHub Profile
@sibelius
sibelius / debugRelay.tsx
Created May 6, 2020 13:23
using JSON.stringify to strip some relay metadata from console.log
const excludeKeys = ['__fragments', '__id', '__fragmentOwner'];
// strip __fragments, __id, __fragmentOwne
const relayTransform = (key: string, value: string) => {
if (excludeKeys.includes(key)) {
return undefined;
}
return value;
};
@sibelius
sibelius / relay.config.js
Created November 17, 2019 00:58
Relay Config that works well with monorepo, you can spread your fragments in many packages
module.exports = {
schema: './data/schema.graphql',
language: 'typescript',
src: '../.',
include: [
'./web/src/**',
'./shared/src/**',
],
};
@bvaughn
bvaughn / eager-prefetching-async-data-example.js
Last active November 30, 2022 21:16
Advanced example for eagerly prefetching async data in a React component.
// This is an advanced example! It is not intended for use in application code.
// Libraries like Relay may make use of this technique to save some time on low-end mobile devices.
// Most components should just initiate async requests in componentDidMount.
class ExampleComponent extends React.Component {
_hasUnmounted = false;
state = {
externalData: null,
};
@eastenluis
eastenluis / map-item.js
Created December 6, 2017 15:18
Mongoose GeoJSON schema example
const mapItemSchema = new mongoose.Schema({
name: String,
location: {
// It's important to define type within type field, because
// mongoose use "type" to identify field's object type.
type: {type: String, default: 'Point'},
// Default value is needed. Mongoose pass an empty array to
// array type by default, but it will fail MongoDB's pre-save
// validation.
coordinates: {type: [Number], default: [0, 0]}
@PurpleBooth
PurpleBooth / README-Template.md
Last active May 28, 2024 08:25
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites