Skip to content

Instantly share code, notes, and snippets.

View yusinto's full-sized avatar
🎯
Focusing

Yusinto Ngadiman yusinto

🎯
Focusing
View GitHub Profile
@yusinto
yusinto / App-snippet.js
Created July 17, 2018 02:09
React site nav list snippet
import aboutMeImage from './about-me.png';
// ... other code omitted for brevity
<ul>
<li>
<img src={aboutMeImage} height="40"/>
<span>About me</span>
</li>
</ul>
@yusinto
yusinto / App.css
Created July 16, 2018 10:22
React site nav content group styles
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
display: flex;
justify-content: center;
align-items: center;
@yusinto
yusinto / App.js
Last active July 16, 2018 10:11
Adding react-site-nav to create-react-app
import React from 'react';
import logo from './logo.svg';
import './App.css';
import SiteNav, {ContentGroup} from 'react-site-nav';
export default () => (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo"/>
<h1 className="App-title">Welcome to React</h1>
@yusinto
yusinto / home.js
Created June 2, 2018 12:11
withFlags usage example
import {withFlags} from 'ld-react';
const Home = props => {
// flags are available via props.flags
return props.flags.devTestFlag ? <div>Flag on</div> : <div>Flag off</div>;
};
export default withFlags(Home);
@yusinto
yusinto / app.js
Last active June 2, 2018 12:11
withFlagProvider example
import {withFlagProvider} from 'ld-react';
import Home from './home';
const App = () =>
<div>
<Home />
</div>;
export default withFlagProvider(App, {clientSideId: 'your-client-side-id'});
@yusinto
yusinto / queryRenderer-snippet.js
Last active April 28, 2018 10:38
Relay modern QueryRenderer snippet to demo schema stitching
<QueryRenderer
environment={relayEnvironment}
query={graphql`
query client_index_Query {
user {
email
name
favouritePlaces {
business { # look ma, remote schema field!
name
@yusinto
yusinto / prisma.query.graphql
Last active April 28, 2018 10:21
Equivalent prisma query
query {
business(where: {publicId: "$place.id"}) { # place.id is supplied by fragment on line 30
id
name
email
address
}
}
@yusinto
yusinto / local.schema.graphql
Last active April 28, 2018 10:01
Example local schema to demonstrate relay and schema stitching
type Query {
user: User
place: Place
}
type User {
email: String
name: String
favouritePlaces: [Place]
}
@yusinto
yusinto / mergedSchema.js
Last active April 28, 2018 10:56
Example merged relay and prisma graphql schema.
import {mergeSchemas, makeRemoteExecutableSchema, makeExecutableSchema} from 'graphql-tools';
import {importSchema} from 'graphql-import';
import {HttpLink} from 'apollo-link-http';
import fetch from 'node-fetch';
import localSchema from './localSchema';
const uri = 'https://eu1.prisma.sh/public-nickelwarrior-830/wendarie-prisma/dev';
const link = new HttpLink({uri, fetch});
// remote.schema.graphql is downloaded in the previous step
@yusinto
yusinto / .graphqlconfig.yml
Created April 28, 2018 06:10
Sample .graphqconfig.yml for relay schema stitching
schemaPath: ./remote.schema.graphql
extensions:
endpoints:
default:
url: https://eu1.prisma.sh/public-nickelwarrior-830/wendarie-prisma/dev