This version of graphql-js
introduces a breaking change to the method signature of the resolve()
method.
Previously, resolve()
had this method signature:
type GraphQLResolveInfo = {
fieldName: string,
fieldASTs: Array,
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<meta name="apple-mobile-web-app-capable" content="yes" /> | |
<title>ePOS-Print</title> | |
<script type="text/javascript"> | |
// URL of ePOS-Print supported TM printer (Version 4.1 or later) | |
var url = 'http://10.0.0.201/cgi-bin/epos/service.cgi'; |
class ChildComponent extends React.Component { | |
render() { | |
const {hello} = this.props.greetings; | |
return <h1>{hello}</h1>; | |
} | |
} | |
const ChildContainer = Relay.createContainer(ChildComponent, { | |
initialVariables: { | |
name: 'A', |
// connect() is a function that injects Redux-related props into your component. | |
// You can inject data and callbacks that change that data by dispatching actions. | |
function connect(mapStateToProps, mapDispatchToProps) { | |
// It lets us inject component as the last step so people can use it as a decorator. | |
// Generally you don't need to worry about it. | |
return function (WrappedComponent) { | |
// It returns a component | |
return class extends React.Component { | |
render() { | |
return ( |
A maintainable application architecture requires that the UI only contain the rendering logic and execute queries and mutations against the underlying data model on the server. A maintainable architecture must not contain any logic for composing "app state" on the client as that would necessarily embed business logic in the client. App state should be persisted to the database and the client projection of it should be composed in the mid tier, and refreshed as mutations occur on the server (and after network interruption) for a highly interactive, realtime UX.
With GraphQL we are able to define an easy-to-change application-level data schema on the server that captures the types and relationships in our data, and wiring it to data sources via resolvers that leverage our db's own query language (or data-oriented, uniform service APIs) to resolve client-specified "queries" and "mutations" against the schema.
We use GraphQL to dyn
var express = require('express'); | |
var path = require('path'); | |
var webpackConfig = require('./webpack.config'); | |
var webpack = require('webpack'); | |
var webpackDevMiddleware = require('webpack-dev-middleware'); | |
var webpackHotMiddleware = require('webpack-hot-middleware'); | |
var proxyMiddleware = require('http-proxy-middleware'); | |
var devConfig = webpackConfig.devServer; | |
var app = express(); |
We will compare ASP.NET and Node.js for backend programming.
Source codes from examples.
This document was published on 21.09.2015 for a freelance employer. Some changes since then (14.02.2016):
async/await
. yield
and await
are used almost in the same way, so I see no point to rewrite the examples.Promise = require 'bluebird' | |
defaultPageSize = 20 | |
paginate = (knex) -> (query, paginationOptions, options) -> | |
if query.fetchAll? | |
model = query | |
query = model.query() |
You got your hands on some data that was leaked from a social network and you want to help the poor people.
Luckily you know a government service to automatically block a list of credit cards.
The service is a little old school though and you have to upload a CSV file in the exact format. The upload fails if the CSV file contains invalid data.
The CSV files should have two columns, Name and Credit Card. Also, it must be named after the following pattern:
YYYYMMDD
.csv.
var AWS = require('aws-sdk'), | |
fs = require('fs'); | |
// http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html#Credentials_from_Disk | |
AWS.config.loadFromPath('./aws-config.json'); | |
// assume you already have the S3 Bucket created, and it is called ierg4210-shopxx-photos | |
var photoBucket = new AWS.S3({params: {Bucket: 'ierg4210-shopxx-photos'}}); | |
function uploadToS3(file, destFileName, callback) { |