Skip to content

Instantly share code, notes, and snippets.

import { ApolloProvider } from 'react-apollo'
import { ApolloClient } from 'apollo-boost'
import EnabledFeatures from './EnabledFeatures'
import FlaggedFeature from './FlaggedFeature'
const client = new ApolloClient()
const App = () => (
<React.Fragment>
import { Query } from 'react-apollo'
import PropTypes from 'prop-types'
import React from 'react'
import { queryEnabledFeatures } from './graphql/query'
class EnabledFeatures extends React.Component {
static propTypes = {
children: PropTypes.func.isRequired
}
import { ApolloProvider } from 'react-apollo'
import { ApolloClient } from 'apollo-boost'
import FlaggedFeature from './FlaggedFeature'
const client = new ApolloClient()
ReactDOM.render(
<ApolloProvider client={client}>
<FlaggedFeature name="feature1">
import { Query } from 'react-apollo'
import PropTypes from 'prop-types'
import React from 'react'
import { queryEnabledFeatures } from './graphql/query'
class FlaggedFeature extends React.Component {
static propTypes = {
children: PropTypes.func.isRequired,
name: PropTypes.string.isRequired
@peaonunes
peaonunes / queryEnabledFeatures.js
Created October 9, 2018 02:34
/* Query from GraphQL API the enabled features */
import gql from 'graphql-tag'
export const queryEnabledFeatures = gql`
query {
enabledFeatures {
name
}
}
`
type Query {
enabledFeatures: [Feature!]!
}
type Feature {
name: String!
}
@peaonunes
peaonunes / QueryCustomClient.jsx
Created August 6, 2018 04:08
Querying using a custom client
// ...
const customClient = new ApolloClient({
uri: "http://other-api/graphql"
});
const Dogs = ({ onDogSelected }) => (
<Query query={GET_DOGS} client={customClient} >
{({ loading, error, data }) => {
if (loading) return "Loading...";
if (error) return `Error! ${error.message}`;
@peaonunes
peaonunes / PropsClient.jsx
Last active August 6, 2018 04:07
Multiple Apollo Clients on React
// https://github.com/apollographql/react-apollo/blob/master/src/Query.tsx#L167
// https://github.com/apollographql/react-apollo/blob/master/src/Mutation.tsx#L120
...
this.client = props.client || context.client;
...
import React from "react";
import { render } from "react-dom";
import { ApolloProvider } from "react-apollo";
import ApolloClient from "apollo-boost";
const client = new ApolloClient({
uri: "https://w5xlvm3vzz.lp.gql.zone/graphql"
});
package com.peao.nunes.hystrix.configuration;
import com.netflix.hystrix.contrib.servopublisher.HystrixServoMetricsPublisher;
import com.netflix.hystrix.strategy.HystrixPlugins;
import com.peao.nunes.hystrix.notifier.CircuitBreakerNotifier;
public class HystrixConfiguration {
public static void configureHystrix(){
HystrixConfiguration.configureEventNotifier();