SlideShare a Scribd company logo
1 of 54
ReactJS for Intermediate #3
Oswald Campesato
Consultant/Training:
www.iquarkt.com
ocampesato@yahoo.com
List of React Code Samples
• 1) react-heat (generates React apps)
• 2) NodeJS + ReactJS (react-hello-world)
• 3) ReactJS + D3 (d3act-master)
• 4) GraphQL (graphql-demo-server)
• 5) GraphQL+Angular 2 (angular2-graphql)
• 6) GraphQL+Express/MongoDB (express-graphql)
• 7) GraphQL+SQLite (graphql-nodejs-newsfeed-master)
• 8) Flux (flux-master)
• 9) Redux+Angular 2 (ngrx-rest-app-master)
• 10) Redux+Angular 2 (angular2-redux-example-master)
• NB: read my-notes.sh and inst2.sh regarding #10
react-heat for ReactJS Apps
• #1: [sudo] npm install react-heat –g
• #2: download zip file: https://github.com/insin/react-heatpack
• #3: npm install
• #4: Contents of index.js:
• import React from 'react’
• export default React.createClass({
• render() {
• return <div>Hello world from react-heat!</div>
• }
• })
• Step #4: heatpack index.js
• Step #5: http://localhost:3000
=> more information: https://github.com/insin/react-heatpack
Node/ReactJS Example
• 1) cd react-hello-world
• 2) npm install
• 3) cd src/client
• 4) open index.html
Node/ReactJS/D3.js Example
• 1) cd d3act-master
• 2) npm install
• 3) npm run examples
• 4) localhost:8080
GraphQL: What is it?
• a schema for graph-oriented data (Facebook/2012)
• well-suited for micro-service style backends
• created for specifying finer-grained queries
• provides interface between client and server
• client requests data from GraphQL server
• data requests are based on GraphQL queries
• => write queries against the schema
GraphQL: What it isn’t
• GQL does not dictate a server language
• GQL does not dictate a storage/back-end
• GQL is a query language without a database
GraphQL: What Does it Do?
• It exposes a single endpoint
• the endpoint parses and executes a query
• The query executes over a type system
• the type system is defined in the application server
• the type system is available via introspection (a GQL API)
GraphQL Server Structure
GraphQL servers have three components:
• 1) GraphQL “core” (JavaScript and other languages)
• 2) Type Definitions (maps app code to internal system)
• 3) Application code (business logic)
GraphQL Core: Five Components
• 1) Frontend lexer/parser: an AST [Relay uses parser]
• 2) Type System: GraphQLObjectType (a class)
• 3) Introspection: for querying types
• 4) Validation: is a query valid in the app’s schema?
• 5) Execution: manage query execution (via the AST)
The GraphiQL IDE
• https://github.com/skevy/graphiql-
app/blob/master/README.md
• https://github.com/skevy/graphiql-app/releases
• OSX: brew cask install graphiql
GraphQL Queries (Interfaces)
• interface Employee {
• id: String!
• fname: String
• lname: String
• }
•
• type Query {
• emp: Employee
• }
GraphQL Queries
• Query:
• {
• emp {
• fname
• }
• }
• Result:
• {
• "data": [{
• "emp": {
• "fname": "John"
• }
• }]
• }
GraphQL Queries
• query EmpNameQuery {
• emp {
• fname
• lname
• }
• }
• The result of the preceding query is here:
• {
• "data": [{
• "emp": {
• "fname": "John",
• "lname": "Smith"
• }
• }]
• }
From REST to GraphQL (1)
• First REST query:
• GET /item/10000
• Result of first REST query:
• {
• item: {
• message: “Learning about graphql”,
• timestamp: 1456781234,
• ownerid: 23000
• }
From REST to GraphQL (2)
• Second REST query:
• GET /owner/23000
• Result of second REST query:
• {
• owner: {
• id: 8000,
• name: “John Smith”,
• homepage: {
• url: http://acme.com/jsmith
• }
• }
From REST to GraphQL (3)
• Execute ONE GraphQL query:
• {
• item (id: 10000) {
• message, timestamp,
• owner { // NB: owner is an object
• id, name,
• homepage {
• url
• }
• }
• }
Useful GraphQL Links
• facebook.github.io/graphql
• github.com/graphql/graphql-js
GraphQL Example (Overview)
• 1) cd graphql-demo-server
• 2) install dependencies: npm install
• 3) create a GraphQL/Node app server: index.js
• 4) launch the GraphQL/Node app:
• node index.js
• 5) create the ReactJS client:
• GraphQLClient.html
• 6) launch the ReactJS client:
• open GraphQLClient.html
GraphQL Node App (package.json)
• {
• "name": "graphql-demo",
• "version": "1.0.0",
• "description": "",
• "main": "index.js",
• "keywords": [],
• "author": "",
• "license": "ISC",
• "dependencies": {
• "express": "^4.13.4",
• "express-graphql": "^0.4.10",
• "graphql": "^0.4.18"
• }
• }
GraphQL Node App (index.js)
• var graphql = require('graphql');
• var graphqlHTTP = require('express-graphql');
• var express = require('express');
• var data = require('./data2.json');
• // Define a user type with three string fields
• var UserType = new graphql.GraphQLObjectType({
• name: 'User',
• fields: function() {
• return {
• id: { type: graphql.GraphQLString },
• fname: { type: graphql.GraphQLString },
• lname: { type: graphql.GraphQLString }
• }
• }
• });
GraphQL Node App (index.js)
• var schema = new graphql.GraphQLSchema({
• query: new graphql.GraphQLObjectType({
• name: 'Query',
• fields: {
• user: {
• type: UserType,
• args: {
• id: { type: graphql.GraphQLString },
• fname: { type: graphql.GraphQLString },
• lname: { type: graphql.GraphQLString }
• },
• resolve: function (_, args) {
• return data[args.id];
• }
• }
• }
• })
• });
GraphQL Node App (data.json)
• {
• "100": {
• "id": "100",
• "fname": "Dan",
• "lname": "Smith"
• },
• "200": {
• "id": "200",
• "fname": "Lee",
• "lname": "Jones"
• },
• "300": {
• "id": "300",
• "fname": "Nick",
• "lname": "Stone"
• }
• }
ReactJS Client Code (1)
• <script type="text/babel">
• class UserInfo extends React.Component {
• constructor() {
• super();
• }
• componentWillMount() {
• this.state = { loading: true, error: null, data: null};
• }
• componentDidMount() {
• this.props.promise.then(
• value => this.setState({loading: false, data: value}),
• error => this.setState({loading: false, error: error}));
• }
ReactJS Client Code (2)
• render() { // this method is part of the UserInfo class
• if (this.state.loading) {
• return <span>Loading...</span>;
• }
• else if (this.state.error !== null) {
• return <span>Error: {this.state.error.message}</span>;
• }
• else {
• let queryArray = [this.state.data];
• let queryInfo = queryArray.map( (row,index) => {
• return <li key={index}>ID: {row.data.user.id} First Name: {row.data.user.fname} Last
Name: {row.data.user.lname}</li>
• })
• return (
• <div> <ul>{queryInfo}</ul> </div>
• )
• }
• }
}
ReactJS Client Code (3)
• let userDetails = "{user(id:%22200%22){fname,lname,id}}";
• let userQuery =
"http://localhost:3000/graphql?query="+userDetails;
• ReactDOM.render( // pass user data to UserInfo
• <UserInfo
• promise={$.getJSON(userQuery)} />,
• document.getElementById("userinfo")
• );
• </script>
Starting the Server and Client
• Step #1 (install the dependencies):
• npm install
• Step #2 (start the GraphQL server) in 1st command shell:
node index.js
• Step #3 (launch the ReactJS client) in 2nd command shell:
open ReactClientGraphQL.html
Second GraphQL Example
• combines Express, MongoDB and Mongoose
• uses express-graphql
• cd graphql-nodejs-master
• npm install
• npm start
• navigate to localhost:8000
Third Example: GraphQL and SQLite
• cd graphql-nodejs-newsfeed-master/
• npm install
• npm start
• sample query:
curl --data "query={ __schema { types { name } } }" localhost:8000
“Instant” GraphQL Server for ReactJS
• https://www.reindex.io
• Create your schema with your types
• Deploy GraphQL API with this command:
reindex schema-push
• Documentation/examples:
https://www.reindex.io/docs/
Falcor: An Alternative to GraphQL?
• Falcor Home Page: http://netflix.github.io/falcor/
• Falcor does not involve a schema
• Single data model (virtual JSON graph)
• JavaScript-like path syntax
• https://github.com/Netflix/falcor
The Flux Pattern
• developed by Facebook (2012?)
• a unidirectional data flow (not MVC)
• complements React's view components
• technology agnostic
• Flux implementations work with Angular 2
• implementations: Redux, Fluxxor, et al
Flux-based Applications
• apps comprise three major parts:
• the dispatcher
• the stores
• the views (React components)
• Components and their flow:
• Action->Dispatcher->Store(s)->View->Action
• Action = Event Type (=verb) + Payload (=data)
A Flux Implementation
• cd flux-master
• npm install
• npm start
• In a second command shell:
• cd flux-master/examples/flux-chat
• npm install
• open index.html
What is Redux?
• One implementation of Flux
• Created by Dan Abramov
• Most popular implementation of Flux
• https://github.com/reactjs/redux
• egghead.io tutorials
A Redux App with Angular 2 (#10)
• 1) cd ngrx-rest-app-master
• 2) npm install
• 3) [sudo] npm install jspm –g
• 4) jspm install
• 5) [sudo] npm install live-server
• 6) live-server
A Redux App with ngrx/Angular 2 (#9)
• 1) cd ngrx-rest-app-master
• 2) npm install
• 3) npm start
• 4) http://localhost:3001
A Redux App with ngrx/Angular 2 (#9)
• 1) client/src/app.ts:
constructor(private itemsService: ItemsService,
private store: Store<AppStore>) {
this.items = itemsService.items;
this.selectedItem = store.select('selectedItem');
this.selectedItem.subscribe(v => console.log(v));
itemsService.loadItems();
}
A Redux App with ngrx/Angular 2 (#9)
• 1) client/src/app.ts:
<items-list [items]="items | async"
(selected)="selectItem($event)"
(deleted)="deleteItem($event)">
</items-list>
• deleteItem(item: Item) {
• this.itemsService.deleteItem(item);
• . . .
• }
A Redux App with ngrx/Angular 2 (#9)
• 1) client/src/items.ts:
• export interface Item {
• id: number;
• name: string;
• description: string;
• };
•
• export interface AppStore {
• items: Item[];
• selectedItem: Item;
• };
A Redux App with ngrx/Angular 2 (#9)
• 1) client/src/items.ts:
deleteItem(item: Item) {
this.http.delete(`${BASE_URL}${item.id}`)
.subscribe(action => this.store.dispatch(
{ type: 'DELETE_ITEM', payload: item }));
}
A Redux App with ngrx/Angular 2 (#9)
• 1) client/src/items.ts:
• export interface Item {
• id: number;
• name: string;
• description: string;
• };
•
• export interface AppStore {
• items: Item[];
• selectedItem: Item;
• };
A Redux App with ngrx/Angular 2 (#9)
• 1) client/src/items.ts:
• export const items = (state: any = [],
• {type, payload}) => {
• let index: number;
• switch (type) {
• case 'ADD_ITEMS':
• return payload;
• case 'CREATE_ITEM':
• return [...state, payload];
• case 'UPDATE_ITEM':
• return state.map(item => {
• return item.id === payload.id ?
• Object.assign({}, item, payload) : item;
• });
A Redux App with ngrx/Angular 2 (#9)
• 1) client/src/items.ts:
• switch (type) {
• . . .
• case 'DELETE_ITEM':
• return state.filter(item => {
• return item.id !== payload.id;
• });
• default:
• return state;
• }
• };
ReactFire versus Redux+Firebase
• ReactFire: a mechanism for communicating
between a React application and Firebase
• ReactFire “bypasses” Redux
• Combine React with Redux and Firebase:
• + insert a Firebase Ref into an action creator
• + when Firebase emits data, create an action
• + the action is sent to the dispatcher (reducer)
Other Flux Implementations
• Alt, flummox, fluxury, mcfly, reflux, etc
• At least 16 implementations
• Note: Relay is also a Flux implementation
• Comparison of Flux implementations:
https://github.com/voronianski/flux-comparison
=> Github links are available as well
What is Relay?
• a JavaScript Framework (Facebook)
• for creating data-driven React apps
• declarative syntax
• works with GraphQL
• creates efficient network requests
• fetches only what is requested
• aggregates queries
• caches data on client
Sample Relay Query
• query UserQuery {
• user(id: "123") {
• name,
• },
• }
Sample Relay Fragment
• fragment UserProfilePhoto on User {
• profilePhoto(size: $size) {
• uri,
• },
• }
Sample Relay Query+Fragment
• query UserQuery {
• user(id: "123") {
• ...UserProfilePhoto,
• },
• }
Sample Relay Query+Edges
• query UserQuery {
• user(id: "123") {
• friends(first: 10) {
• edges {
• node {
• ...UserProfilePhoto,
• },
• },
• },
• },
• }
Miscellaneous Topics (1)
• Combining TypeScript with ReactJS:
https://github.com/ServiceStackApps/typescript-redux
• Very good article regarding webpack:
https://medium.com/@rajaraodv/webpack-the-confusing-
parts-58712f8fcad9
React Hot Module / HMR (Hot Module Reloading):
https://github.com/gaearon/react-hot-loader/pull/240
Miscellaneous Topics (2)
• Time travel debugging:
https://code-cartoons.com/hot-reloading-and-time-travel-
debugging-what-are-they-3c8ed2812f35#.fqf5b9uwd
GraphQL and PostgreSQL:
https://github.com/calebmer/postgraphql
#1: sudo npm install -g postgraphql
#2: postgraphql postgres://localhost:5432/mydb --schema
forum --development
Recent/Upcoming Books and Training
1) HTML5 Canvas and CSS3 Graphics (2013)
2) jQuery, CSS3, and HTML5 for Mobile (2013)
3) HTML5 Pocket Primer (2013)
4) jQuery Pocket Primer (2013)
5) HTML5 Mobile Pocket Primer (2014)
6) D3 Pocket Primer (2015)
7) Python Pocket Primer (2015)
8) SVG Pocket Primer (2016)
9) CSS3 Pocket Primer (2016)
10) Angular 2 Pocket Primer (2016)

More Related Content

What's hot

Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsYakov Fain
 
The Many Ways to Test Your React App
The Many Ways to Test Your React AppThe Many Ways to Test Your React App
The Many Ways to Test Your React AppAll Things Open
 
Continuous integration and delivery for java based web applications
Continuous integration and delivery for java based web applicationsContinuous integration and delivery for java based web applications
Continuous integration and delivery for java based web applicationsSunil Dalal
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation ToolIzzet Mustafaiev
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFXHendrik Ebbers
 
Testcontainers - Geekout EE 2017 presentation
Testcontainers - Geekout EE 2017 presentationTestcontainers - Geekout EE 2017 presentation
Testcontainers - Geekout EE 2017 presentationRichard North
 
Asp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework CoreAsp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework Coremohamed elshafey
 
The Gist of React Native
The Gist of React NativeThe Gist of React Native
The Gist of React NativeDarren Cruse
 
Continuous Delivery with Jenkins Workflow
Continuous Delivery with Jenkins WorkflowContinuous Delivery with Jenkins Workflow
Continuous Delivery with Jenkins WorkflowUdaypal Aarkoti
 
Rundeck + Nexus (from Nexus Live on June 5, 2014)
Rundeck + Nexus (from Nexus Live on June 5, 2014)Rundeck + Nexus (from Nexus Live on June 5, 2014)
Rundeck + Nexus (from Nexus Live on June 5, 2014)dev2ops
 
Game of Streams: How to Tame and Get the Most from Your Messaging Platforms
Game of Streams: How to Tame and Get the Most from Your Messaging PlatformsGame of Streams: How to Tame and Get the Most from Your Messaging Platforms
Game of Streams: How to Tame and Get the Most from Your Messaging PlatformsVMware Tanzu
 
PVS-Studio in the Clouds: Azure DevOps
PVS-Studio in the Clouds: Azure DevOpsPVS-Studio in the Clouds: Azure DevOps
PVS-Studio in the Clouds: Azure DevOpsAndrey Karpov
 
Introduction in the play framework
Introduction in the play frameworkIntroduction in the play framework
Introduction in the play frameworkAlexander Reelsen
 
Delivery Pipeline as Code: using Jenkins 2.0 Pipeline
Delivery Pipeline as Code: using Jenkins 2.0 PipelineDelivery Pipeline as Code: using Jenkins 2.0 Pipeline
Delivery Pipeline as Code: using Jenkins 2.0 PipelineSlawa Giterman
 
High Performance NodeJS
High Performance NodeJSHigh Performance NodeJS
High Performance NodeJSDicoding
 
Node.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideNode.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideMek Srunyu Stittri
 

What's hot (20)

Using JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot appsUsing JHipster for generating Angular/Spring Boot apps
Using JHipster for generating Angular/Spring Boot apps
 
Introduction to gradle
Introduction to gradleIntroduction to gradle
Introduction to gradle
 
The Many Ways to Test Your React App
The Many Ways to Test Your React AppThe Many Ways to Test Your React App
The Many Ways to Test Your React App
 
Continuous integration and delivery for java based web applications
Continuous integration and delivery for java based web applicationsContinuous integration and delivery for java based web applications
Continuous integration and delivery for java based web applications
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation Tool
 
Apache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolboxApache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolbox
 
React native
React nativeReact native
React native
 
Test Driven Development with JavaFX
Test Driven Development with JavaFXTest Driven Development with JavaFX
Test Driven Development with JavaFX
 
Testcontainers - Geekout EE 2017 presentation
Testcontainers - Geekout EE 2017 presentationTestcontainers - Geekout EE 2017 presentation
Testcontainers - Geekout EE 2017 presentation
 
Asp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework CoreAsp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework Core
 
The Gist of React Native
The Gist of React NativeThe Gist of React Native
The Gist of React Native
 
Git Overview
Git OverviewGit Overview
Git Overview
 
Continuous Delivery with Jenkins Workflow
Continuous Delivery with Jenkins WorkflowContinuous Delivery with Jenkins Workflow
Continuous Delivery with Jenkins Workflow
 
Rundeck + Nexus (from Nexus Live on June 5, 2014)
Rundeck + Nexus (from Nexus Live on June 5, 2014)Rundeck + Nexus (from Nexus Live on June 5, 2014)
Rundeck + Nexus (from Nexus Live on June 5, 2014)
 
Game of Streams: How to Tame and Get the Most from Your Messaging Platforms
Game of Streams: How to Tame and Get the Most from Your Messaging PlatformsGame of Streams: How to Tame and Get the Most from Your Messaging Platforms
Game of Streams: How to Tame and Get the Most from Your Messaging Platforms
 
PVS-Studio in the Clouds: Azure DevOps
PVS-Studio in the Clouds: Azure DevOpsPVS-Studio in the Clouds: Azure DevOps
PVS-Studio in the Clouds: Azure DevOps
 
Introduction in the play framework
Introduction in the play frameworkIntroduction in the play framework
Introduction in the play framework
 
Delivery Pipeline as Code: using Jenkins 2.0 Pipeline
Delivery Pipeline as Code: using Jenkins 2.0 PipelineDelivery Pipeline as Code: using Jenkins 2.0 Pipeline
Delivery Pipeline as Code: using Jenkins 2.0 Pipeline
 
High Performance NodeJS
High Performance NodeJSHigh Performance NodeJS
High Performance NodeJS
 
Node.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideNode.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java side
 

Viewers also liked

A Journey with React
A Journey with ReactA Journey with React
A Journey with ReactFITC
 
An Intense Overview of the React Ecosystem
An Intense Overview of the React EcosystemAn Intense Overview of the React Ecosystem
An Intense Overview of the React EcosystemRami Sayar
 
Michael Porter Strategy
Michael Porter StrategyMichael Porter Strategy
Michael Porter StrategyAnoop Ismail
 
Michael Porter's Competitive Advantage
Michael Porter's Competitive AdvantageMichael Porter's Competitive Advantage
Michael Porter's Competitive AdvantageWesley Shu
 
What is strategy by Michael Porter
What is strategy by Michael PorterWhat is strategy by Michael Porter
What is strategy by Michael Porterhitnrun10
 

Viewers also liked (7)

A Journey with React
A Journey with ReactA Journey with React
A Journey with React
 
An Intense Overview of the React Ecosystem
An Intense Overview of the React EcosystemAn Intense Overview of the React Ecosystem
An Intense Overview of the React Ecosystem
 
Bubble Meetup presentation
Bubble Meetup presentationBubble Meetup presentation
Bubble Meetup presentation
 
Michael Porter Strategy
Michael Porter StrategyMichael Porter Strategy
Michael Porter Strategy
 
Michael Porter's Competitive Advantage
Michael Porter's Competitive AdvantageMichael Porter's Competitive Advantage
Michael Porter's Competitive Advantage
 
Negotiation ppt
Negotiation pptNegotiation ppt
Negotiation ppt
 
What is strategy by Michael Porter
What is strategy by Michael PorterWhat is strategy by Michael Porter
What is strategy by Michael Porter
 

Similar to React inter3

Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Loiane Groner
 
Rapid application development with spring roo j-fall 2010 - baris dere
Rapid application development with spring roo   j-fall 2010 - baris dereRapid application development with spring roo   j-fall 2010 - baris dere
Rapid application development with spring roo j-fall 2010 - baris dereBaris Dere
 
Running Airflow Workflows as ETL Processes on Hadoop
Running Airflow Workflows as ETL Processes on HadoopRunning Airflow Workflows as ETL Processes on Hadoop
Running Airflow Workflows as ETL Processes on Hadoopclairvoyantllc
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application TestingTroy Miles
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN StackTroy Miles
 
How to Contribute to Apache Usergrid
How to Contribute to Apache UsergridHow to Contribute to Apache Usergrid
How to Contribute to Apache UsergridDavid M. Johnson
 
Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework BasicMario Romano
 
React state management with Redux and MobX
React state management with Redux and MobXReact state management with Redux and MobX
React state management with Redux and MobXDarko Kukovec
 
GraphQL_devoxx_2023.pptx
GraphQL_devoxx_2023.pptxGraphQL_devoxx_2023.pptx
GraphQL_devoxx_2023.pptxSoham Dasgupta
 
Hadoop cluster performance profiler
Hadoop cluster performance profilerHadoop cluster performance profiler
Hadoop cluster performance profilerIhor Bobak
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileAmazon Web Services Japan
 
Microservices and modularity with java
Microservices and modularity with javaMicroservices and modularity with java
Microservices and modularity with javaDPC Consulting Ltd
 

Similar to React inter3 (20)

Angular2 inter3
Angular2 inter3Angular2 inter3
Angular2 inter3
 
Graphql usage
Graphql usageGraphql usage
Graphql usage
 
Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018Angular for Java Enterprise Developers: Oracle Code One 2018
Angular for Java Enterprise Developers: Oracle Code One 2018
 
Gradle
GradleGradle
Gradle
 
Rapid application development with spring roo j-fall 2010 - baris dere
Rapid application development with spring roo   j-fall 2010 - baris dereRapid application development with spring roo   j-fall 2010 - baris dere
Rapid application development with spring roo j-fall 2010 - baris dere
 
Running Airflow Workflows as ETL Processes on Hadoop
Running Airflow Workflows as ETL Processes on HadoopRunning Airflow Workflows as ETL Processes on Hadoop
Running Airflow Workflows as ETL Processes on Hadoop
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application Testing
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
 
How to Contribute to Apache Usergrid
How to Contribute to Apache UsergridHow to Contribute to Apache Usergrid
How to Contribute to Apache Usergrid
 
ReactJS for Beginners
ReactJS for BeginnersReactJS for Beginners
ReactJS for Beginners
 
GraphQL-ify your APIs
GraphQL-ify your APIsGraphQL-ify your APIs
GraphQL-ify your APIs
 
Angular2
Angular2Angular2
Angular2
 
Alfresco Development Framework Basic
Alfresco Development Framework BasicAlfresco Development Framework Basic
Alfresco Development Framework Basic
 
React state management with Redux and MobX
React state management with Redux and MobXReact state management with Redux and MobX
React state management with Redux and MobX
 
GraphQL_devoxx_2023.pptx
GraphQL_devoxx_2023.pptxGraphQL_devoxx_2023.pptx
GraphQL_devoxx_2023.pptx
 
Iac d.damyanov 4.pptx
Iac d.damyanov 4.pptxIac d.damyanov 4.pptx
Iac d.damyanov 4.pptx
 
Hadoop cluster performance profiler
Hadoop cluster performance profilerHadoop cluster performance profiler
Hadoop cluster performance profiler
 
Java 8
Java 8Java 8
Java 8
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
 
Microservices and modularity with java
Microservices and modularity with javaMicroservices and modularity with java
Microservices and modularity with java
 

More from Oswald Campesato

Working with tf.data (TF 2)
Working with tf.data (TF 2)Working with tf.data (TF 2)
Working with tf.data (TF 2)Oswald Campesato
 
Introduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasIntroduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasOswald Campesato
 
Introduction to Deep Learning
Introduction to Deep LearningIntroduction to Deep Learning
Introduction to Deep LearningOswald Campesato
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2Oswald Campesato
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2Oswald Campesato
 
"An Introduction to AI and Deep Learning"
"An Introduction to AI and Deep Learning""An Introduction to AI and Deep Learning"
"An Introduction to AI and Deep Learning"Oswald Campesato
 
Introduction to Deep Learning, Keras, and Tensorflow
Introduction to Deep Learning, Keras, and TensorflowIntroduction to Deep Learning, Keras, and Tensorflow
Introduction to Deep Learning, Keras, and TensorflowOswald Campesato
 
Introduction to Deep Learning for Non-Programmers
Introduction to Deep Learning for Non-ProgrammersIntroduction to Deep Learning for Non-Programmers
Introduction to Deep Learning for Non-ProgrammersOswald Campesato
 
TensorFlow in Your Browser
TensorFlow in Your BrowserTensorFlow in Your Browser
TensorFlow in Your BrowserOswald Campesato
 
Deep Learning in Your Browser
Deep Learning in Your BrowserDeep Learning in Your Browser
Deep Learning in Your BrowserOswald Campesato
 
Deep Learning and TensorFlow
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlowOswald Campesato
 
Introduction to Deep Learning and TensorFlow
Introduction to Deep Learning and TensorFlowIntroduction to Deep Learning and TensorFlow
Introduction to Deep Learning and TensorFlowOswald Campesato
 
Intro to Deep Learning, TensorFlow, and tensorflow.js
Intro to Deep Learning, TensorFlow, and tensorflow.jsIntro to Deep Learning, TensorFlow, and tensorflow.js
Intro to Deep Learning, TensorFlow, and tensorflow.jsOswald Campesato
 
Deep Learning and TensorFlow
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlowOswald Campesato
 
Introduction to Deep Learning and Tensorflow
Introduction to Deep Learning and TensorflowIntroduction to Deep Learning and Tensorflow
Introduction to Deep Learning and TensorflowOswald Campesato
 
Deep Learning, Scala, and Spark
Deep Learning, Scala, and SparkDeep Learning, Scala, and Spark
Deep Learning, Scala, and SparkOswald Campesato
 
Deep Learning in your Browser: powered by WebGL
Deep Learning in your Browser: powered by WebGLDeep Learning in your Browser: powered by WebGL
Deep Learning in your Browser: powered by WebGLOswald Campesato
 
Deep Learning, Keras, and TensorFlow
Deep Learning, Keras, and TensorFlowDeep Learning, Keras, and TensorFlow
Deep Learning, Keras, and TensorFlowOswald Campesato
 

More from Oswald Campesato (20)

Working with tf.data (TF 2)
Working with tf.data (TF 2)Working with tf.data (TF 2)
Working with tf.data (TF 2)
 
Introduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and KerasIntroduction to TensorFlow 2 and Keras
Introduction to TensorFlow 2 and Keras
 
Introduction to Deep Learning
Introduction to Deep LearningIntroduction to Deep Learning
Introduction to Deep Learning
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2
 
Introduction to TensorFlow 2
Introduction to TensorFlow 2Introduction to TensorFlow 2
Introduction to TensorFlow 2
 
"An Introduction to AI and Deep Learning"
"An Introduction to AI and Deep Learning""An Introduction to AI and Deep Learning"
"An Introduction to AI and Deep Learning"
 
H2 o berkeleydltf
H2 o berkeleydltfH2 o berkeleydltf
H2 o berkeleydltf
 
Introduction to Deep Learning, Keras, and Tensorflow
Introduction to Deep Learning, Keras, and TensorflowIntroduction to Deep Learning, Keras, and Tensorflow
Introduction to Deep Learning, Keras, and Tensorflow
 
Introduction to Deep Learning for Non-Programmers
Introduction to Deep Learning for Non-ProgrammersIntroduction to Deep Learning for Non-Programmers
Introduction to Deep Learning for Non-Programmers
 
TensorFlow in Your Browser
TensorFlow in Your BrowserTensorFlow in Your Browser
TensorFlow in Your Browser
 
Deep Learning in Your Browser
Deep Learning in Your BrowserDeep Learning in Your Browser
Deep Learning in Your Browser
 
Deep Learning and TensorFlow
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlow
 
Introduction to Deep Learning and TensorFlow
Introduction to Deep Learning and TensorFlowIntroduction to Deep Learning and TensorFlow
Introduction to Deep Learning and TensorFlow
 
Intro to Deep Learning, TensorFlow, and tensorflow.js
Intro to Deep Learning, TensorFlow, and tensorflow.jsIntro to Deep Learning, TensorFlow, and tensorflow.js
Intro to Deep Learning, TensorFlow, and tensorflow.js
 
Deep Learning and TensorFlow
Deep Learning and TensorFlowDeep Learning and TensorFlow
Deep Learning and TensorFlow
 
Introduction to Deep Learning and Tensorflow
Introduction to Deep Learning and TensorflowIntroduction to Deep Learning and Tensorflow
Introduction to Deep Learning and Tensorflow
 
Deep Learning, Scala, and Spark
Deep Learning, Scala, and SparkDeep Learning, Scala, and Spark
Deep Learning, Scala, and Spark
 
Deep Learning in your Browser: powered by WebGL
Deep Learning in your Browser: powered by WebGLDeep Learning in your Browser: powered by WebGL
Deep Learning in your Browser: powered by WebGL
 
Deep Learning, Keras, and TensorFlow
Deep Learning, Keras, and TensorFlowDeep Learning, Keras, and TensorFlow
Deep Learning, Keras, and TensorFlow
 
C++ and Deep Learning
C++ and Deep LearningC++ and Deep Learning
C++ and Deep Learning
 

Recently uploaded

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 

Recently uploaded (20)

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 

React inter3

  • 1. ReactJS for Intermediate #3 Oswald Campesato Consultant/Training: www.iquarkt.com ocampesato@yahoo.com
  • 2. List of React Code Samples • 1) react-heat (generates React apps) • 2) NodeJS + ReactJS (react-hello-world) • 3) ReactJS + D3 (d3act-master) • 4) GraphQL (graphql-demo-server) • 5) GraphQL+Angular 2 (angular2-graphql) • 6) GraphQL+Express/MongoDB (express-graphql) • 7) GraphQL+SQLite (graphql-nodejs-newsfeed-master) • 8) Flux (flux-master) • 9) Redux+Angular 2 (ngrx-rest-app-master) • 10) Redux+Angular 2 (angular2-redux-example-master) • NB: read my-notes.sh and inst2.sh regarding #10
  • 3. react-heat for ReactJS Apps • #1: [sudo] npm install react-heat –g • #2: download zip file: https://github.com/insin/react-heatpack • #3: npm install • #4: Contents of index.js: • import React from 'react’ • export default React.createClass({ • render() { • return <div>Hello world from react-heat!</div> • } • }) • Step #4: heatpack index.js • Step #5: http://localhost:3000 => more information: https://github.com/insin/react-heatpack
  • 4. Node/ReactJS Example • 1) cd react-hello-world • 2) npm install • 3) cd src/client • 4) open index.html
  • 5. Node/ReactJS/D3.js Example • 1) cd d3act-master • 2) npm install • 3) npm run examples • 4) localhost:8080
  • 6. GraphQL: What is it? • a schema for graph-oriented data (Facebook/2012) • well-suited for micro-service style backends • created for specifying finer-grained queries • provides interface between client and server • client requests data from GraphQL server • data requests are based on GraphQL queries • => write queries against the schema
  • 7. GraphQL: What it isn’t • GQL does not dictate a server language • GQL does not dictate a storage/back-end • GQL is a query language without a database
  • 8. GraphQL: What Does it Do? • It exposes a single endpoint • the endpoint parses and executes a query • The query executes over a type system • the type system is defined in the application server • the type system is available via introspection (a GQL API)
  • 9. GraphQL Server Structure GraphQL servers have three components: • 1) GraphQL “core” (JavaScript and other languages) • 2) Type Definitions (maps app code to internal system) • 3) Application code (business logic)
  • 10. GraphQL Core: Five Components • 1) Frontend lexer/parser: an AST [Relay uses parser] • 2) Type System: GraphQLObjectType (a class) • 3) Introspection: for querying types • 4) Validation: is a query valid in the app’s schema? • 5) Execution: manage query execution (via the AST)
  • 11. The GraphiQL IDE • https://github.com/skevy/graphiql- app/blob/master/README.md • https://github.com/skevy/graphiql-app/releases • OSX: brew cask install graphiql
  • 12. GraphQL Queries (Interfaces) • interface Employee { • id: String! • fname: String • lname: String • } • • type Query { • emp: Employee • }
  • 13. GraphQL Queries • Query: • { • emp { • fname • } • } • Result: • { • "data": [{ • "emp": { • "fname": "John" • } • }] • }
  • 14. GraphQL Queries • query EmpNameQuery { • emp { • fname • lname • } • } • The result of the preceding query is here: • { • "data": [{ • "emp": { • "fname": "John", • "lname": "Smith" • } • }] • }
  • 15. From REST to GraphQL (1) • First REST query: • GET /item/10000 • Result of first REST query: • { • item: { • message: “Learning about graphql”, • timestamp: 1456781234, • ownerid: 23000 • }
  • 16. From REST to GraphQL (2) • Second REST query: • GET /owner/23000 • Result of second REST query: • { • owner: { • id: 8000, • name: “John Smith”, • homepage: { • url: http://acme.com/jsmith • } • }
  • 17. From REST to GraphQL (3) • Execute ONE GraphQL query: • { • item (id: 10000) { • message, timestamp, • owner { // NB: owner is an object • id, name, • homepage { • url • } • } • }
  • 18. Useful GraphQL Links • facebook.github.io/graphql • github.com/graphql/graphql-js
  • 19. GraphQL Example (Overview) • 1) cd graphql-demo-server • 2) install dependencies: npm install • 3) create a GraphQL/Node app server: index.js • 4) launch the GraphQL/Node app: • node index.js • 5) create the ReactJS client: • GraphQLClient.html • 6) launch the ReactJS client: • open GraphQLClient.html
  • 20. GraphQL Node App (package.json) • { • "name": "graphql-demo", • "version": "1.0.0", • "description": "", • "main": "index.js", • "keywords": [], • "author": "", • "license": "ISC", • "dependencies": { • "express": "^4.13.4", • "express-graphql": "^0.4.10", • "graphql": "^0.4.18" • } • }
  • 21. GraphQL Node App (index.js) • var graphql = require('graphql'); • var graphqlHTTP = require('express-graphql'); • var express = require('express'); • var data = require('./data2.json'); • // Define a user type with three string fields • var UserType = new graphql.GraphQLObjectType({ • name: 'User', • fields: function() { • return { • id: { type: graphql.GraphQLString }, • fname: { type: graphql.GraphQLString }, • lname: { type: graphql.GraphQLString } • } • } • });
  • 22. GraphQL Node App (index.js) • var schema = new graphql.GraphQLSchema({ • query: new graphql.GraphQLObjectType({ • name: 'Query', • fields: { • user: { • type: UserType, • args: { • id: { type: graphql.GraphQLString }, • fname: { type: graphql.GraphQLString }, • lname: { type: graphql.GraphQLString } • }, • resolve: function (_, args) { • return data[args.id]; • } • } • } • }) • });
  • 23. GraphQL Node App (data.json) • { • "100": { • "id": "100", • "fname": "Dan", • "lname": "Smith" • }, • "200": { • "id": "200", • "fname": "Lee", • "lname": "Jones" • }, • "300": { • "id": "300", • "fname": "Nick", • "lname": "Stone" • } • }
  • 24. ReactJS Client Code (1) • <script type="text/babel"> • class UserInfo extends React.Component { • constructor() { • super(); • } • componentWillMount() { • this.state = { loading: true, error: null, data: null}; • } • componentDidMount() { • this.props.promise.then( • value => this.setState({loading: false, data: value}), • error => this.setState({loading: false, error: error})); • }
  • 25. ReactJS Client Code (2) • render() { // this method is part of the UserInfo class • if (this.state.loading) { • return <span>Loading...</span>; • } • else if (this.state.error !== null) { • return <span>Error: {this.state.error.message}</span>; • } • else { • let queryArray = [this.state.data]; • let queryInfo = queryArray.map( (row,index) => { • return <li key={index}>ID: {row.data.user.id} First Name: {row.data.user.fname} Last Name: {row.data.user.lname}</li> • }) • return ( • <div> <ul>{queryInfo}</ul> </div> • ) • } • } }
  • 26. ReactJS Client Code (3) • let userDetails = "{user(id:%22200%22){fname,lname,id}}"; • let userQuery = "http://localhost:3000/graphql?query="+userDetails; • ReactDOM.render( // pass user data to UserInfo • <UserInfo • promise={$.getJSON(userQuery)} />, • document.getElementById("userinfo") • ); • </script>
  • 27. Starting the Server and Client • Step #1 (install the dependencies): • npm install • Step #2 (start the GraphQL server) in 1st command shell: node index.js • Step #3 (launch the ReactJS client) in 2nd command shell: open ReactClientGraphQL.html
  • 28. Second GraphQL Example • combines Express, MongoDB and Mongoose • uses express-graphql • cd graphql-nodejs-master • npm install • npm start • navigate to localhost:8000
  • 29. Third Example: GraphQL and SQLite • cd graphql-nodejs-newsfeed-master/ • npm install • npm start • sample query: curl --data "query={ __schema { types { name } } }" localhost:8000
  • 30. “Instant” GraphQL Server for ReactJS • https://www.reindex.io • Create your schema with your types • Deploy GraphQL API with this command: reindex schema-push • Documentation/examples: https://www.reindex.io/docs/
  • 31. Falcor: An Alternative to GraphQL? • Falcor Home Page: http://netflix.github.io/falcor/ • Falcor does not involve a schema • Single data model (virtual JSON graph) • JavaScript-like path syntax • https://github.com/Netflix/falcor
  • 32. The Flux Pattern • developed by Facebook (2012?) • a unidirectional data flow (not MVC) • complements React's view components • technology agnostic • Flux implementations work with Angular 2 • implementations: Redux, Fluxxor, et al
  • 33. Flux-based Applications • apps comprise three major parts: • the dispatcher • the stores • the views (React components) • Components and their flow: • Action->Dispatcher->Store(s)->View->Action • Action = Event Type (=verb) + Payload (=data)
  • 34. A Flux Implementation • cd flux-master • npm install • npm start • In a second command shell: • cd flux-master/examples/flux-chat • npm install • open index.html
  • 35. What is Redux? • One implementation of Flux • Created by Dan Abramov • Most popular implementation of Flux • https://github.com/reactjs/redux • egghead.io tutorials
  • 36. A Redux App with Angular 2 (#10) • 1) cd ngrx-rest-app-master • 2) npm install • 3) [sudo] npm install jspm –g • 4) jspm install • 5) [sudo] npm install live-server • 6) live-server
  • 37. A Redux App with ngrx/Angular 2 (#9) • 1) cd ngrx-rest-app-master • 2) npm install • 3) npm start • 4) http://localhost:3001
  • 38. A Redux App with ngrx/Angular 2 (#9) • 1) client/src/app.ts: constructor(private itemsService: ItemsService, private store: Store<AppStore>) { this.items = itemsService.items; this.selectedItem = store.select('selectedItem'); this.selectedItem.subscribe(v => console.log(v)); itemsService.loadItems(); }
  • 39. A Redux App with ngrx/Angular 2 (#9) • 1) client/src/app.ts: <items-list [items]="items | async" (selected)="selectItem($event)" (deleted)="deleteItem($event)"> </items-list> • deleteItem(item: Item) { • this.itemsService.deleteItem(item); • . . . • }
  • 40. A Redux App with ngrx/Angular 2 (#9) • 1) client/src/items.ts: • export interface Item { • id: number; • name: string; • description: string; • }; • • export interface AppStore { • items: Item[]; • selectedItem: Item; • };
  • 41. A Redux App with ngrx/Angular 2 (#9) • 1) client/src/items.ts: deleteItem(item: Item) { this.http.delete(`${BASE_URL}${item.id}`) .subscribe(action => this.store.dispatch( { type: 'DELETE_ITEM', payload: item })); }
  • 42. A Redux App with ngrx/Angular 2 (#9) • 1) client/src/items.ts: • export interface Item { • id: number; • name: string; • description: string; • }; • • export interface AppStore { • items: Item[]; • selectedItem: Item; • };
  • 43. A Redux App with ngrx/Angular 2 (#9) • 1) client/src/items.ts: • export const items = (state: any = [], • {type, payload}) => { • let index: number; • switch (type) { • case 'ADD_ITEMS': • return payload; • case 'CREATE_ITEM': • return [...state, payload]; • case 'UPDATE_ITEM': • return state.map(item => { • return item.id === payload.id ? • Object.assign({}, item, payload) : item; • });
  • 44. A Redux App with ngrx/Angular 2 (#9) • 1) client/src/items.ts: • switch (type) { • . . . • case 'DELETE_ITEM': • return state.filter(item => { • return item.id !== payload.id; • }); • default: • return state; • } • };
  • 45. ReactFire versus Redux+Firebase • ReactFire: a mechanism for communicating between a React application and Firebase • ReactFire “bypasses” Redux • Combine React with Redux and Firebase: • + insert a Firebase Ref into an action creator • + when Firebase emits data, create an action • + the action is sent to the dispatcher (reducer)
  • 46. Other Flux Implementations • Alt, flummox, fluxury, mcfly, reflux, etc • At least 16 implementations • Note: Relay is also a Flux implementation • Comparison of Flux implementations: https://github.com/voronianski/flux-comparison => Github links are available as well
  • 47. What is Relay? • a JavaScript Framework (Facebook) • for creating data-driven React apps • declarative syntax • works with GraphQL • creates efficient network requests • fetches only what is requested • aggregates queries • caches data on client
  • 48. Sample Relay Query • query UserQuery { • user(id: "123") { • name, • }, • }
  • 49. Sample Relay Fragment • fragment UserProfilePhoto on User { • profilePhoto(size: $size) { • uri, • }, • }
  • 50. Sample Relay Query+Fragment • query UserQuery { • user(id: "123") { • ...UserProfilePhoto, • }, • }
  • 51. Sample Relay Query+Edges • query UserQuery { • user(id: "123") { • friends(first: 10) { • edges { • node { • ...UserProfilePhoto, • }, • }, • }, • }, • }
  • 52. Miscellaneous Topics (1) • Combining TypeScript with ReactJS: https://github.com/ServiceStackApps/typescript-redux • Very good article regarding webpack: https://medium.com/@rajaraodv/webpack-the-confusing- parts-58712f8fcad9 React Hot Module / HMR (Hot Module Reloading): https://github.com/gaearon/react-hot-loader/pull/240
  • 53. Miscellaneous Topics (2) • Time travel debugging: https://code-cartoons.com/hot-reloading-and-time-travel- debugging-what-are-they-3c8ed2812f35#.fqf5b9uwd GraphQL and PostgreSQL: https://github.com/calebmer/postgraphql #1: sudo npm install -g postgraphql #2: postgraphql postgres://localhost:5432/mydb --schema forum --development
  • 54. Recent/Upcoming Books and Training 1) HTML5 Canvas and CSS3 Graphics (2013) 2) jQuery, CSS3, and HTML5 for Mobile (2013) 3) HTML5 Pocket Primer (2013) 4) jQuery Pocket Primer (2013) 5) HTML5 Mobile Pocket Primer (2014) 6) D3 Pocket Primer (2015) 7) Python Pocket Primer (2015) 8) SVG Pocket Primer (2016) 9) CSS3 Pocket Primer (2016) 10) Angular 2 Pocket Primer (2016)