This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { USER_INFOMATION_QUERY, USER_NOTIFICATION_QUERY, USER_INFOMATION_MUTATION } from './user.graphql' | |
import { graphql, compose } from 'react-apollo' | |
import UserInfomationComponent from './user.component' | |
// need to defined shape of | |
// prop types from enhanced component | |
type UserInfomationContainerPropTypes = { | |
userId: string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { USER_INFOMATION_QUERY, USER_NOTIFICATION_QUERY, USER_INFOMATION_MUTATION } from './user.graphql' | |
import { graphql, compose } from 'react-apollo' | |
import UserInfomationComponent from './user.component' | |
// need to defined shape of | |
// prop types from enhanced component | |
type UserInfomationContainerPropTypes = { | |
userId: string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function graphql< | |
TProps extends TGraphQLVariables | {} = {}, | |
TData = {}, | |
TGraphQLVariables = {}, | |
TChildProps = Partial<DataProps<TData, TGraphQLVariables>> & | |
Partial<MutateProps<TData, TGraphQLVariables>> | |
>( | |
document: DocumentNode, | |
operationOptions: OperationOption<TProps, TData, TGraphQLVariables, TChildProps> = {}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react' | |
import { graphql } from 'react-apollo' | |
import gql from 'graphql-tag' | |
const USER_INFOMATION_QUERY = gql` | |
query { | |
user { | |
_id | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// on client request | |
const xhr = new XMLHttpRequest() | |
// request to api endpoint | |
xhr.open('post', '/documents.zip') | |
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8') | |
xhr.onprogress = () => { | |
// receive stream | |
console.log('PROGRESS:', xhr.responseText) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const momentTimeZone = require('moment-timezone'); | |
function getBKKTime() { | |
const date = new Date() | |
const UTCDateString = date.toISOString() | |
const BKKDateString = moment.tz(UTCDateString, 'Asia/Bangkok').format() | |
return BKKDateString; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const rawSchema = { | |
typeDefs: ` | |
type Query { | |
gqlTools: String | |
} | |
`, | |
resolvers: { | |
Query: { | |
gqlTools: () => 'Hi from gqlTools' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
graphqlExpress(req => { | |
const extendContext = require('./graphql').getGraphQLExtendedContext(req) | |
// } | |
return ({ | |
schema, | |
tracing, | |
context: { | |
...req, | |
...extendContext | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import { ApolloProvider, getDataFromTree } from 'react-apollo' | |
import 'isomorphic-fetch' | |
import { sessionQuery } from './withSession' | |
import apolloClientFactory from '../../common/apolloClientFactory' | |
export default (Component) => class withData extends React.Component { | |
static async getInitialProps (context) { | |
if (typeof window === 'undefined') { | |
const props = { | |
user: context.req.user, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.container { | |
background: black; | |
display: flex; | |
flex-direction: column; | |
position: relative; | |
height: 100vh; | |
align-items: center; | |
justify-content: center; | |
box-sizing: border-box; | |
color: #f5f6f8; |