GRANDstack: Graphs ALL The Way Down William Lyon @lyonwj - - PowerPoint PPT Presentation

grandstack graphs all the way down
SMART_READER_LITE
LIVE PREVIEW

GRANDstack: Graphs ALL The Way Down William Lyon @lyonwj - - PowerPoint PPT Presentation

GRANDstack: Graphs ALL The Way Down William Lyon @lyonwj lyonwj.com bit.ly/GRANDstack William Lyon @lyonwj Neo4j Labs Engineer @lyonwj GRANDstack.io Agenda Whats a GRANDstack ? Building a #NODES2019 Recommendations App


slide-1
SLIDE 1

GRANDstack: Graphs ALL The Way Down

William Lyon @lyonwj lyonwj.com bit.ly/GRANDstack

slide-2
SLIDE 2

@lyonwj GRANDstack.io

William Lyon

@lyonwj

Neo4j Labs Engineer

slide-3
SLIDE 3
  • What’s a GRANDstack?
  • Building a #NODES2019

Recommendations App

  • Hunger Games

@lyonwj

Agenda

GRANDstack.io

slide-4
SLIDE 4

@lyonwj GRANDstack.io

  • Fullstack framework for building applications

Fullstack GraphQL with GRANDstack

grandstack.io

slide-5
SLIDE 5

@lyonwj GRANDstack.io

What is GraphQL?

GraphQL.org

An API query language and runtime for building APIs

slide-6
SLIDE 6

@lyonwj GRANDstack.io

“Your Application Data Is A Graph”

  • - GraphQL
slide-7
SLIDE 7

@lyonwj GRANDstack.io

Expose A GraphQL API From Neo4j

GRANDstack.io

slide-8
SLIDE 8

@lyonwj GRANDstack.io

  • Fullstack framework for building applications

Fullstack GraphQL with GRANDstack

grandstack.io

slide-9
SLIDE 9

@lyonwj

nodes2019-app.grandstack.io

GRANDstack.io

slide-10
SLIDE 10
  • Mid 1990s:

○ Static HTML ○ CGI and PHP ○ LAMP Stack

  • ~2000s:

○ REST APIs, JSON ○ jQuery

  • ~2010s:

○ NoSQL ○ MEAN Stack ○ Meteor.js

@lyonwj

Evolution of Web Dev

GRANDstack.io

slide-11
SLIDE 11
  • 2010s to...

○ React (open sourced in 2013) ■ Mental model of server side JS to client ■ Move from event listeners to declarative actions about state ■ Virtual DOM ○ GraphQL (open sourced in 2015) ■ Efficient data fetching ■ Data type system - describe and query your API as a graph ○ Graph databases ■ Intuitive graph datamodel ■ Native graph query performance ○ Deployment, serverless, DX over Cloud services

@lyonwj

Evolution of Web Dev

GRANDstack.io

slide-12
SLIDE 12

@lyonwj GRANDstack.io

“Your Application Data Is A Graph”

  • - GraphQL
slide-13
SLIDE 13

NODES Conference Graph

@lyonwj GRANDstack.io

849a4698.databases.neo4j.io/browser/

slide-14
SLIDE 14

NODES Schedule GraphQL API

@lyonwj GRANDstack.io

nodes2019.grandstack.io

slide-15
SLIDE 15

Movies, Genres, Directors, Actors

@lyonwj

slide-16
SLIDE 16

Movies, Genres, Directors, Actors

GraphQL Type Definitions

  • Defined using GraphQL

Schema Definition Language (SDL)

@lyonwj

slide-17
SLIDE 17

Movies, Genres, Directors, Actors

Introspection

  • Schema can be queried
  • Schema becomes API specification /

documentation

  • Tools like GraphiQL / GraphQL

Playground

@lyonwj

slide-18
SLIDE 18

Movies, Genres, Directors, Actors

GraphQL query

@lyonwj

slide-19
SLIDE 19

https://blog.apollographql.com/the-anatomy-of-a-graphql-query-6dffa9e9e747 Operation name and arguments

@lyonwj

slide-20
SLIDE 20

Selection set

@lyonwj

https://blog.apollographql.com/the-anatomy-of-a-graphql-query-6dffa9e9e747

slide-21
SLIDE 21

GraphQL query

Movies, Genres, Directors, Actors

@lyonwj

slide-22
SLIDE 22

GraphQL query GraphQL response

Movies, Genres, Directors, Actors

@lyonwj

slide-23
SLIDE 23

1) GraphQL is an API query language, not a database query language. 2) Limited expressivity (no projections, no aggregations, etc). 3) While GraphQL exposes your application data as a graph, it’s not (just) for graph databases

What is GraphQL?

@lyonwj

slide-24
SLIDE 24
  • Overfetching

○ Less data over the wire

  • Underfetching

○ Single round trip

  • GraphQL Specification
  • “Graphs All The Way Down”

○ Relationships vs Resources ○ Unify disparate systems (microservices)

  • Simplify data fetching

○ Component based data interactions

GraphQL Advantages

@lyonwj

slide-25
SLIDE 25
  • Some well understood practices from

REST don’t apply ○ HTTP status codes ○ Errors ○ Caching

  • Exposing arbitrary complexity to client

○ Performance considerations

  • n+1 query problem
  • Query costing / rate limiting

GraphQL Challenges

@lyonwj

slide-26
SLIDE 26

@lyonwj

REST In Practice - R.I.P.?

GRANDstack.io

slide-27
SLIDE 27

How To Build A GraphQL Service

slide-28
SLIDE 28

Start With A GraphQL Schema

graphql.org/learn/schema/#type-language

@lyonwj

slide-29
SLIDE 29
  • Functions that define how to “resolve” data for GraphQL request

GraphQL Resolvers

graphql.org/learn/execution/#root-fields-resolvers

@lyonwj

slide-30
SLIDE 30

Resolvers

@lyonwj

slide-31
SLIDE 31

1) Schema Duplication 2) Mapping / translation layer from graph ←→ (???) 3) Boilerplate code 4) n+1 query problem

Common Problems With This Approach

https://blog.grandstack.io/five-common-graphql-problems-and-how-neo4j-graphql-aims-to-solve-them-e9a8999c8d43

@lyonwj

slide-32
SLIDE 32

GraphQL “Engines”

slide-33
SLIDE 33
  • Tools for auto-generating GraphQL schema, generating

database queries from GraphQL requests

GraphQL “Engines” Overview

prisma.io aws.amazon.com/appsync hasura.io graphile.org grandstack.io Neo4j-GraphQL

@lyonwj

slide-34
SLIDE 34

Neo4j-GraphQL

slide-35
SLIDE 35
  • GraphQL First Development

○ GraphQL schema drives the database data model

  • Generate Cypher from GraphQL

○ Single query / single round trip to database

  • Generate GraphQL CRUD API from type definitions
  • Auto-generated resolvers (no boilerplate!)
  • Extend GraphQL functionality with Cypher

○ @cypher schema directive

Goals for Neo4j-GraphQL Integration

@lyonwj

slide-36
SLIDE 36

GraphQL First Development

@lyonwj

slide-37
SLIDE 37

Auto-generate GraphQL CRUD API

@lyonwj

  • Query & Mutation types

○ Entry point for each type

  • Ordering
  • Pagination
  • Complex Filter
  • DateTime types

https://blog.grandstack.io/complex-graphql-filtering-with-neo4j-graphql-js-aef19ad06c3e

slide-38
SLIDE 38

Generate Cypher From GraphQL

@lyonwj

slide-39
SLIDE 39

Extend GraphQL w/ Cypher

grandstack.io/docs/neo4j-graphql-js.html#cypher-directive

@cypher GraphQL schema directive

@lyonwj

slide-40
SLIDE 40

www.npmjs.com/package/neo4j-graphql-js

@lyonwj

slide-41
SLIDE 41

neo4j-graphql-js

neo4j-graphql-js apollo-server

@lyonwj

slide-42
SLIDE 42

Demo

GRANDstack starter project grandstack.io

https://github.com/grand-stack/grand-stack-starter/tree/master/api/src

@lyonwj

slide-43
SLIDE 43

GRANDstack.io

@lyonwj

slide-44
SLIDE 44
  • Declarative database integrations for

GraphQL

  • GraphQL type definitions define

database model

  • Provision CRUD GraphQL API

○ Auto-generated GraphQL API ○ Schema enrichments

  • Generate database queries

○ auto-generated resolvers ○ reduce boilerplate

GraphQL ”Engines”

@lyonwj

slide-45
SLIDE 45

How Do GraphQL Engines Generate Database Queries From GraphQL Requests?

resolveInfo resolver argument

  • GraphQL query AST
  • GraphQL schema
  • Selection set
  • Variables
  • ...

@lyonwj

slide-46
SLIDE 46

@lyonwj GRANDstack.io

summit.graphql.com

Use code “SPEAKERFRIEND” for a 15% discount!!!

slide-47
SLIDE 47

@lyonwj GRANDstack.io

github.com/johnymontana/NODES2019-GRANDstack

slide-48
SLIDE 48

GRANDstack Starter Project

@lyonwj GRANDstack.io

github.com/grand-stack/grand-stack-starter

slide-49
SLIDE 49

GRANDstack Starter Project

@lyonwj GRANDstack.io

github.com/grand-stack/grand-stack-starter

slide-50
SLIDE 50

Who’s using GRANDstack & Neo4j GraphQL?

@lyonwj GRANDstack.io

slide-51
SLIDE 51

Who’s using GRANDstack & Neo4j GraphQL?

@lyonwj GRANDstack.io

community.neo4j.com

slide-52
SLIDE 52

Who’s using GRANDstack & Neo4j GraphQL?

@lyonwj GRANDstack.io

medium.com/ft-product-technology/ready-steady-crash-eeae63e89a77 speakerdeck.com/wheresrhys/a-field-guide-to-the-financial-times

slide-53
SLIDE 53

Who’s using GRANDstack & Neo4j GraphQL?

@lyonwj GRANDstack.io

community.neo4j.com/t/online-meetup-using-neo4j-and-graphql-to-build-human-connection/8213

slide-54
SLIDE 54

foundation.graphql.org

@lyonwj GRANDstack.io

slide-55
SLIDE 55

GRANDstack Talks In #NODES2019

@lyonwj GRANDstack.io

nodes2019-app.grandstack.io neo4j.com/online-summit

slide-56
SLIDE 56

@lyonwj GRANDstack.io

summit.graphql.com

Use code “SPEAKERFRIEND” for a 15% discount!!!

slide-57
SLIDE 57

GRANDstack.io/survey

@lyonwj GRANDstack.io

slide-58
SLIDE 58

@lyonwj

blog.grandstack.io

GRANDstack.io

slide-59
SLIDE 59

@lyonwj GRANDstack.io

GRANDstack.io

slide-60
SLIDE 60

Hunger Games Questions for

"GRANDstack: Graphs ALL The Way Down"

Query the GraphQL Playground at nodes2019.grandstack.io to answer: 1. What is the title of the first session when ordered by title in ascending order?

a. APOC Pearls: The Best Tips & Tricks b. Agile Property Graph Design Process c. Aardvarks In The Cloud With Neo4j Fabric

2. Which speakers are presenting talks about Kafka?

a. Bob Loblaw and Princess Caroline b. Mark Needham and Andrea Santurbano c. Michael Hunger and Craig Taverner

3. If I like the talk about Neovis.js, what is the top recommendation for me?

a. Graph Visualization: Main aspects, challenges and solutions b. Building Spatial Search Algorithms for Neo4j c. Challenges in knowledge graph visualization

Answer here: r.neo4j.com/hunger-games