+ All Categories
Home > Documents > Defining Property Graph Schemas using the …olafhartig.de/slides/W3CWorkshop2019GraphQLSDL4PGs.pdfm...

Defining Property Graph Schemas using the …olafhartig.de/slides/W3CWorkshop2019GraphQLSDL4PGs.pdfm...

Date post: 09-Jul-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
14
Defining Property Graph Schemas using the GraphQL Schema Definion Language Olaf Harg @olaarg
Transcript
Page 1: Defining Property Graph Schemas using the …olafhartig.de/slides/W3CWorkshop2019GraphQLSDL4PGs.pdfm a g e s o u r c e: h t t p: / / t i n k e r p o p. a p a c h e. o r g / d o c s

Defining Property Graph Schemas using the GraphQL Schema Definition LanguageOlaf Hartig@olafhartig

Page 2: Defining Property Graph Schemas using the …olafhartig.de/slides/W3CWorkshop2019GraphQLSDL4PGs.pdfm a g e s o u r c e: h t t p: / / t i n k e r p o p. a p a c h e. o r g / d o c s

2Olaf Hartig - Defining Property Graph Schemas using the GraphQL Schema Definition 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

Page 3: Defining Property Graph Schemas using the …olafhartig.de/slides/W3CWorkshop2019GraphQLSDL4PGs.pdfm a g e s o u r c e: h t t p: / / t i n k e r p o p. a p a c h e. o r g / d o c s

3Olaf Hartig - Defining Property Graph Schemas using the GraphQL Schema Definition Language

GraphQL Schema Definition Language (SDL)

● Language to define GraphQL schema

● Specifies the types of objects that can be queriedwhen accessing a specific GraphQL Web API

Page 4: Defining Property Graph Schemas using the …olafhartig.de/slides/W3CWorkshop2019GraphQLSDL4PGs.pdfm a g e s o u r c e: h t t p: / / t i n k e r p o p. a p a c h e. o r g / d o c s

4Olaf Hartig - Defining Property Graph Schemas using the GraphQL Schema Definition 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 ofan interface type and an implementation

declaration ofa union typedeclaration ofa union type

declaration of the query type

(possible root fields of queries)

Page 5: Defining Property Graph Schemas using the …olafhartig.de/slides/W3CWorkshop2019GraphQLSDL4PGs.pdfm a g e s o u r c e: h t t p: / / t i n k e r p o p. a p a c h e. o r g / d o c s

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

Page 6: Defining Property Graph Schemas using the …olafhartig.de/slides/W3CWorkshop2019GraphQLSDL4PGs.pdfm a g e s o u r c e: h t t p: / / t i n k e r p o p. a p a c h e. o r g / d o c s

6Olaf Hartig - Defining Property Graph Schemas using the GraphQL Schema Definition Language

Property Graph Schemas with GraphQL SDL

Imag

e s

ourc

e: h

ttp://

tinke

rpop

.apa

che.

org

/do

cs/3

.4.0

/tuto

rials

/get

ting

-sta

rted

/

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}

Page 7: Defining Property Graph Schemas using the …olafhartig.de/slides/W3CWorkshop2019GraphQLSDL4PGs.pdfm a g e s o u r c e: h t t p: / / t i n k e r p o p. a p a c h e. o r g / d o c s

7Olaf Hartig - Defining Property Graph Schemas using the GraphQL Schema Definition Language

Node Types and Node Properties

type UserSession {  id: ID!  user: User!  startTime: Time  endTime: Time}

scalar Time

type User {  id: ID!  loginName: String!   name: String}

Page 8: Defining Property Graph Schemas using the …olafhartig.de/slides/W3CWorkshop2019GraphQLSDL4PGs.pdfm a g e s o u r c e: h t t p: / / t i n k e r p o p. a p a c h e. o r g / d o c s

8Olaf Hartig - Defining Property Graph Schemas using the GraphQL Schema Definition Language

(Outgoing) Edges

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

type C {  otherC: [C!] @distinct @noloops   b: [B]  @distinct}

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

Page 9: Defining Property Graph Schemas using the …olafhartig.de/slides/W3CWorkshop2019GraphQLSDL4PGs.pdfm a g e s o u r c e: h t t p: / / t i n k e r p o p. a p a c h e. o r g / d o c s

9Olaf Hartig - Defining Property Graph Schemas using the GraphQL Schema Definition Language

Cardinality Restrictions

● 1:1 relationship

● 1:N relationship

● N:1 relationship

● N:M relationship

rel: B  @uniqueForTarget

rel: B

rel: [B]  @uniqueForTarget

rel: [B]

Page 10: Defining Property Graph Schemas using the …olafhartig.de/slides/W3CWorkshop2019GraphQLSDL4PGs.pdfm a g e s o u r c e: h t t p: / / t i n k e r p o p. a p a c h e. o r g / d o c s

10Olaf Hartig - Defining Property Graph Schemas using the GraphQL Schema Definition Language

Multiple 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!}

Page 11: Defining Property Graph Schemas using the …olafhartig.de/slides/W3CWorkshop2019GraphQLSDL4PGs.pdfm a g e s o u r c e: h t t p: / / t i n k e r p o p. a p a c h e. o r g / d o c s

11Olaf Hartig - Defining Property Graph Schemas using the GraphQL Schema Definition Language

Multiple 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!}

Page 12: Defining Property Graph Schemas using the …olafhartig.de/slides/W3CWorkshop2019GraphQLSDL4PGs.pdfm a g e s o u r c e: h t t p: / / t i n k e r p o p. a p a c h e. o r g / d o c s

12Olaf Hartig - Defining Property Graph Schemas using the GraphQL Schema Definition Language

Multiple Types of Source Nodes

type Car {  brand: String!  color: String  owner: Person}

type Motorcycle {  brand: String!  owner: Person}

type Person {  name: String!}

Page 13: Defining Property Graph Schemas using the …olafhartig.de/slides/W3CWorkshop2019GraphQLSDL4PGs.pdfm a g e s o u r c e: h t t p: / / t i n k e r p o p. a p a c h e. o r g / d o c s

13Olaf Hartig - Defining Property Graph Schemas using the GraphQL Schema Definition Language

Edge Properties

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

Page 14: Defining Property Graph Schemas using the …olafhartig.de/slides/W3CWorkshop2019GraphQLSDL4PGs.pdfm a g e s o u r c e: h t t p: / / t i n k e r p o p. a p a c h e. o r g / d o c s

www.liu.se


Recommended