Skip to content

Instantly share code, notes, and snippets.

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

Yuttana K. Thunderbird7

🏠
Working from home
View GitHub Profile
// แสดงเฉพาะสิ่งที่สำคัญ
// ...
import { graphql } from 'react-apollo'
import gql from 'graphql-tag';
class App extends Component {
// ...
render() {
@Thunderbird7
Thunderbird7 / ApolloQueryAction.js
Last active January 11, 2017 14:37
Apollo Query Redux
// Apollo Client query in Action...
import apolloClient from './client'
import gql from 'graphql-tag'
const client = apolloClient()
export function getMyProfile() {
const myQuery = {
query: gql`
query {
profile {
import ApolloClient, { createNetworkInterface } from 'apollo-client'
export default function client() {
const networkInterface = createNetworkInterface({
uri: 'https://localhost/graphql'
})
const apolloClient = new ApolloClient({ networkInterface })
return apolloClient
}
// RNConfig.h
#import <React/RCTBridgeModule.h>
@interface RNConfig : NSObject<RCTBridgeModule>
@end
// RNConfig.m
#import "RNConfig.h"
#define kEnvironment "BuildEnvironment"
// environment configure
{
"development": {
"apiURL": "https://myapi-dev.company.com",
"codepushKey": "YOUR_KEY"
},
"staging": {
"apiURL": "https://myapi-staging.company.com",
"codepushKey": "YOUR_KEY"
},
import { NativeModules } from 'react-native'
import Config from 'config.json'
const environment = NativeModules.RNConfig.buildEnvironment
const getAPIURL = () => {
console.log('Current ENV: ', environment)
return Config[environment].apiURL
}
export default {