GraphCoQL A mechanized formalization of GraphQL in Coq Tomás Díaz Federico Olmedo Éric Tanter Millennium Institute Foundational Research on Data Certified Programs and Proofs New Orleans, USA — January 2020
GraphQL Clases de cátedra Language for specifying the interfaces of web data services and their query mechanism 2
GraphQL Clases de cátedra Language for specifying the interfaces of web data services and their query mechanism HTTP GET 2
GraphQL Clases de cátedra Language for specifying the interfaces of web data services and their query mechanism query { artist(id:1000) { name artworks(role: ACTOR) { title } } } HTTP GET 2
GraphQL Clases de cátedra Language for specifying the interfaces of web data services and their query mechanism query { artist(id:1000) { name artworks(role: ACTOR) { title } } } HTTP GET 2
GraphQL Clases de cátedra Language for specifying the interfaces of web data services and their query mechanism query { artist(id:1000) { name artworks(role: ACTOR) { title } } } HTTP GET 2
GraphQL Clases de cátedra Language for specifying the interfaces of web data services and their query mechanism query { artist(id:1000) { name artworks(role: ACTOR) { title } } } HTTP GET 2
GraphQL Clases de cátedra Language for specifying the interfaces of web data services and their query mechanism query { artist(id:1000) { name artworks(role: ACTOR) { title } } } HTTP GET { “artist” : { “name” : “Tom Hanks”, “artworks” : [ { “title” : “Toy Story”, }, { “title” : “Forrest Gump”, }, … ] } } 2
GraphQL Clases de cátedra Language for specifying the interfaces of web data services and their query mechanism query { artist(id:1000) { name artworks(role: ACTOR) { title } } } HTTP GET { “artist” : { “name” : “Tom Hanks”, “artworks” : [ { “title” : “Toy Story”, }, { “title” : “Forrest Gump”, }, … ] } } 2
GraphQL Clases de cátedra Language for specifying the interfaces of web data services and their query mechanism query { artist(id:1000) { name artworks(role: ACTOR) { title } } } HTTP GET { “artist” : { “name” : “Tom Hanks”, “artworks” : [ { “title” : “Toy Story”, }, { “title” : “Forrest Gump”, }, … ] } } 2
Industry involvement with GraphQL Clases de cátedra 2012 2015+ 3
First language formalization [Hartig & Pérez, WWW’18] Clases de cátedra Paper & pencil formalization to study complexity properties. ( f : � ( u , f [ � ] ) if ( u , f [ � ] ) 2 dom ( � ) J f [ � ] K u G = else. f : null ( ` : � ( u , f [ � ] ) if ( u , f [ � ] ) 2 dom ( � ) J ` : f [ � ] K u G = ` : null else. f :[{ J � K � 1 G } · · · { J � K � k G }] if type S ( f ) 2 L T and { � 1 , ... , � k } = { � i | ( u , f [ � ] , � i ) 2 E } J f [ � ] { � } K u f :{ J � K � G } if type S ( f ) < L T and ( u , f [ � ] , � ) 2 E G = f : null if type S ( f ) < L T and there is no � 2 N s.t. ( u , f [ � ] , � ) 2 E ` :[{ J � K � 1 G } · · · { J � K � k G }] if type S ( f ) 2 L T and { � 1 , ... , � k } = { � i | ( u , f [ � ] , � i ) 2 E } J ` : f [ � ] { � } K u ` :{ J � K � G } if type S ( f ) < L T and ( u , f [ � ] , � ) 2 E G = ` : null if type S ( f ) < L T and there is no � 2 N s.t. ( u , f [ � ] , � ) 2 E J � K u if t 2 O T and � ( u ) = t , or t 2 I T and � ( u ) 2 implementation S ( t ) , or G J on t { � } K u t 2 U T and � ( u ) 2 union S ( t ) G = � in other case. J � 1 · · · � k K u G = collect ( J � 1 K u G · · · J � k K u G ) Figure 5: Semantics of a GraphQL query. 4
First language formalization [Hartig & Pérez, WWW’18] Clases de cátedra Paper & pencil formalization to study complexity properties. Missing proofs about fundamental properties ( f : � ( u , f [ � ] ) if ( u , f [ � ] ) 2 dom ( � ) J f [ � ] K u G = else. f : null ( ` : � ( u , f [ � ] ) if ( u , f [ � ] ) 2 dom ( � ) J ` : f [ � ] K u G = ` : null else. f :[{ J � K � 1 G } · · · { J � K � k G }] if type S ( f ) 2 L T and { � 1 , ... , � k } = { � i | ( u , f [ � ] , � i ) 2 E } J f [ � ] { � } K u f :{ J � K � G } if type S ( f ) < L T and ( u , f [ � ] , � ) 2 E G = f : null if type S ( f ) < L T and there is no � 2 N s.t. ( u , f [ � ] , � ) 2 E ` :[{ J � K � 1 G } · · · { J � K � k G }] if type S ( f ) 2 L T and { � 1 , ... , � k } = { � i | ( u , f [ � ] , � i ) 2 E } J ` : f [ � ] { � } K u ` :{ J � K � G } if type S ( f ) < L T and ( u , f [ � ] , � ) 2 E G = ` : null if type S ( f ) < L T and there is no � 2 N s.t. ( u , f [ � ] , � ) 2 E J � K u if t 2 O T and � ( u ) = t , or t 2 I T and � ( u ) 2 implementation S ( t ) , or G J on t { � } K u t 2 U T and � ( u ) 2 union S ( t ) G = � in other case. J � 1 · · · � k K u G = collect ( J � 1 K u G · · · J � k K u G ) Figure 5: Semantics of a GraphQL query. 4
Our contribution Clases de cátedra GraphCoQL First mechanized formalization of GraphQL in the Coq proof assistant 5
Schema Clases de cátedra Describes how data is structured and queried enum Role { type Artist { ACTOR id: ID DIRECTOR name: String WRITER artworks(role:Role): [Artwork] } } interface Movie { union Artwork = Fiction id: ID | Animation title: String | Book year: Int cast: [Artist] } type Book { … } type Fiction implements Movie { … type Query { } artist(id:ID): Artist movie(id:ID): Movie type Animation implements Movie { } … style: Style } 6
Schema Clases de cátedra Describes how data is structured and queried enum Role { type Artist { ACTOR id: ID DIRECTOR object name: String WRITER type artworks(role:Role): [Artwork] } } interface Movie { union Artwork = Fiction id: ID | Animation title: String | Book year: Int cast: [Artist] } type Book { … } type Fiction implements Movie { … type Query { } artist(id:ID): Artist movie(id:ID): Movie type Animation implements Movie { } … style: Style } 6
Schema Clases de cátedra Describes how data is structured and queried enum Role { type Artist { ACTOR id: ID DIRECTOR object name: String WRITER type artworks(role:Role): [Artwork] } } interface Movie { union Artwork = Fiction id: ID | Animation title: String interface | Book year: Int type cast: [Artist] } type Book { … } type Fiction implements Movie { … type Query { } artist(id:ID): Artist movie(id:ID): Movie type Animation implements Movie { } … style: Style } 6
Schema Clases de cátedra Describes how data is structured and queried enum Role { type Artist { ACTOR id: ID DIRECTOR object name: String WRITER type artworks(role:Role): [Artwork] } } interface Movie { union Artwork = Fiction id: ID | Animation title: String interface | Book year: Int type cast: [Artist] } type Book { … } type Fiction implements Movie { … type Query { } artist(id:ID): Artist movie(id:ID): Movie type Animation implements Movie { } … style: Style } 6
Schema Clases de cátedra Describes how data is structured and queried enum Role { type Artist { enumeration ACTOR id: ID type DIRECTOR object name: String WRITER type artworks(role:Role): [Artwork] } } interface Movie { union Artwork = Fiction id: ID | Animation title: String interface | Book year: Int type cast: [Artist] } type Book { … } type Fiction implements Movie { … type Query { } artist(id:ID): Artist movie(id:ID): Movie type Animation implements Movie { } … style: Style } 6
Schema Clases de cátedra Describes how data is structured and queried enum Role { type Artist { enumeration ACTOR id: ID type DIRECTOR object name: String WRITER type artworks(role:Role): [Artwork] } } interface Movie { union Artwork = Fiction union type id: ID | Animation title: String interface | Book year: Int type cast: [Artist] } type Book { … } type Fiction implements Movie { … type Query { } artist(id:ID): Artist movie(id:ID): Movie type Animation implements Movie { } … style: Style } 6
Schema Clases de cátedra Describes how data is structured and queried enum Role { type Artist { enumeration ACTOR id: ID type DIRECTOR object name: String WRITER type artworks(role:Role): [Artwork] } } interface Movie { union Artwork = Fiction union type id: ID | Animation title: String interface | Book year: Int type cast: [Artist] } type Book { … } type Fiction implements Movie { … type Query { entry points } artist(id:ID): Artist for querying movie(id:ID): Movie type Animation implements Movie { the dataset } … style: Style } 6
Schema Clases de cátedra Describes how data is structured and queried 7
Graph data model Clases de cátedra Datasets are modeled as directed property graphs, with labeled edges and typed nodes. 8
Graph data model Clases de cátedra Datasets are modeled as directed property graphs, with labeled edges and typed nodes. Artist id : 1000 name : “Tom Hanks” 8
Recommend
More recommend