Defjning Property Graph Schemas using the GraphQL Schema Defjnitjon - - PowerPoint PPT Presentation

defjning property graph schemas using the graphql schema
SMART_READER_LITE
LIVE PREVIEW

Defjning Property Graph Schemas using the GraphQL Schema Defjnitjon - - PowerPoint PPT Presentation

Defjning Property Graph Schemas using the GraphQL Schema Defjnitjon Language Olaf Hartjg @olafiartjg What is GraphQL? State-of-the art approach to create Web APIs to retrieve data for Web and mobile applications Alternative to the


slide-1
SLIDE 1

Defjning Property Graph Schemas using the GraphQL Schema Defjnitjon Language

Olaf Hartjg

@olafiartjg

slide-2
SLIDE 2

2 Olaf Hartjg - Defjning Property Graph Schemas using the GraphQL Schema Defjnitjon Language

What is GraphQL?

  • State-of-the art approach to create Web APIs to retrieve

data for Web and mobile applications

  • Alternative to the notion of REST-based Web APIs
  • Developed and used by Facebook since 2012
  • Made available to the public (open source) in 2015

– Spec and reference implementation

  • Based on a simple, JSON-like query language
slide-3
SLIDE 3

3 Olaf Hartjg - Defjning Property Graph Schemas using the GraphQL Schema Defjnitjon Language

GraphQL Schema Defjnitjon Language (SDL)

  • Language to define GraphQL schema
  • Specifies the types of objects that can be queried

when accessing a specific GraphQL Web API

slide-4
SLIDE 4

4 Olaf Hartjg - Defjning Property Graph Schemas using the GraphQL Schema Defjnitjon Language

GraphQL SDL Example

declaration of an object type with its fields and their types argument declaration of an object type with its fields and their types declaration of an interface type and an implementation declaration of a union type declaration of a union type declaration of the query type (possible root fields of queries)

slide-5
SLIDE 5

Can we use this language to defjne schemas for Property Graphs?

slide-6
SLIDE 6

6 Olaf Hartjg - Defjning Property Graph Schemas using the GraphQL Schema Defjnitjon Language

Property Graph Schemas with GraphQL SDL

Image source: http://tinkerpop.apache.org/docs/3.4.0/tutorials/getting-started/

Example Property Graph schema defined using the GraphQL SDL

type person { name: String! age: Int knows(weight:Float!): [person] @distinct @noloops created(weight:Float!): [software] @distinct @requiredForTarget } type software { name: String! lang: Language } enum Language { java javascript python }

slide-7
SLIDE 7

7 Olaf Hartjg - Defjning Property Graph Schemas using the GraphQL Schema Defjnitjon Language

Node Types and Node Propertjes

type UserSession { id: ID! user: User! startTime: Time endTime: Time } scalar Time type User { id: ID! loginName: String! name: String }

slide-8
SLIDE 8

8 Olaf Hartjg - Defjning Property Graph Schemas using the GraphQL Schema Defjnitjon Language

(Outgoing) Edges

type A { type B { name: String! favoriteA: A! favoriteB: B otherA: [A!] relatedA: [A] } } type C {

  • therC: [C!] @distinct @noloops

b: [B] @distinct } type D { a: [A] @uniqueForTarget b: [B] @requiredForTarget c: [C] @uniqueForTarget @requiredForTarget }

slide-9
SLIDE 9

9 Olaf Hartjg - Defjning Property Graph Schemas using the GraphQL Schema Defjnitjon Language

Cardinality Restrictjons

  • 1:1 relationship
  • 1:N relationship
  • N:1 relationship
  • N:M relationship

rel: B @uniqueForTarget rel: B rel: [B] @uniqueForTarget rel: [B]

slide-10
SLIDE 10

10 Olaf Hartjg - Defjning Property Graph Schemas using the GraphQL Schema Defjnitjon Language

Multjple Types of Target Nodes 1/2

type Person { id: ID! name: String! favoriteVehicle: Vehicle } union Vehicle = Car | Motorcycle type Car { brand: String! color: String } type Motorcycle { brand: String! }

slide-11
SLIDE 11

11 Olaf Hartjg - Defjning Property Graph Schemas using the GraphQL Schema Defjnitjon Language

Multjple Types of Target Nodes 2/2

type Person { id: ID! name: String! favoriteVehicle: Vehicle } interface Vehicle { brand: String! }

type Car implements Vehicle { brand: String! color: String } type Motorcycle implements Vehicle { brand: String! }

slide-12
SLIDE 12

12 Olaf Hartjg - Defjning Property Graph Schemas using the GraphQL Schema Defjnitjon Language

Multjple Types of Source Nodes

type Car { brand: String! color: String

  • wner: Person

} type Motorcycle { brand: String!

  • wner: Person

} type Person { name: String! }

slide-13
SLIDE 13

13 Olaf Hartjg - Defjning Property Graph Schemas using the GraphQL Schema Defjnitjon Language

Edge Propertjes

type UserSession { id: ID! user(certainty:Float! comment:String): User! startTime: Time endTime: Time }

slide-14
SLIDE 14

www.liu.se