GRAPH YOUR
ENTERPRISE
Introduction
They are everywhere inside your
company, your clients and partners...
APIs
@GraphQLPortal - www.graphql-portal.com
API are products
APIs are in your microserivces
Headless


APIs
@GraphQLPortal - www.graphql-portal.com
APIs


in


IoT
@GraphQLPortal - www.graphql-portal.com
Some history
f
irst
APIs are not a new hot topic
.
1991
CORBA
1993
RDA
1998
XML-RPC
1999
SOAP
2005
JSON-RPC
2015
GRAPHQL
2000
REST
2007
ODATA
2016
gRPC
1988
ONC RPC
@GraphQLPortal - www.graphql-portal.com
PIM
TrustPilot
Shipping
ERP
Prix
dynamiques
Shopify
Social
Recommendation
Video
DAM
REST
@GraphQLPortal - www.graphql-portal.com
Overfetching
- can you make me an endpoint
with *just* a photo and a title?
getProductBySKU(…)


getProducts(…)


getProductTitle(…)


getProductPhotos(…)


getProductMainPhoto(…)


getListOfProductsWithPhoto(…)


getListOfProductsAUserLikes(…)


getListOfProductsIMightLikeButNotSu
- OK!
@GraphQLPortal - www.graphql-portal.com
Underfetching
Catalogue
Avis
&
Commentaires
Shipping
ERP
Prix
dynamiques
E-Commerce
Social
Recommendation
Video DAM
getProductSKU(…)


getPriceForClient(SKU, clientID)


addToCart(SKU, cartID)


getRecommendedProducts(SKU, clientID)


getReviews(SKU)


BDD AS/400
API REST
API SOAP
API REST
What I get from getServers(…)


YAML
JSON
XML
?
@GraphQLPortal - www.graphql-portal.com
GraphQL
2012
Created in Facebook to
support mobile apps.
2015 2018
Open-sourced by
Facebook,
fi
rst draft
of speci
fi
cations
Governance moving
from Facebook to
GraphQL foundation
Some story...
@GraphQLPortal - www.graphql-portal.com
But What is GraphQL ?
"We don’t think of data in terms of resource
URLs, secondary keys, or join tables; we think
about it in terms of a graph of objects and the
models we ultimately use in our apps like
NSObjects or JSON."




- Lee Byron, creator of GraphQL
@GraphQLPortal - www.graphql-portal.com
How it works?
1. Describe your data using type
system de
fi
nition (schéma)
2. Ask what you need,
executable de
fi
nition (query)
3. Get predictable results
Types
type Query {


allMedia: [Media]


firstMedia: Media


getMedia(id: Int!): Media


total: Int


}


union Media = Movie | Franchise


type Movie {


id: Int!


title: Title


genre: Genre


}
Returns a list of 'Media'
This argument is required
Union of two types
This
fi
eld can't be null
enum Genre {


ADVENTURE


COMEDY


HORROR


WEBINAR


}
This 'enum' is used for options
Quick facts
GraphQL is a strongly typed, hierachical protocol
which de
fi
nes business objects of your enterprise.


It o
ff
ers introspection and simpli
fi
es (removes?)
versionning.
@GraphQLPortal - www.graphql-portal.com
10 Problems GraphQL Solves
1. Introduces proper Data Fetching


2. Solves Overfetching / Underfetching


3. Reduces waste of Network Requests


4. Brings Flexibility to the Static Nature of APIs


5. Makes Resource Deprecations Easy


6. Makes Evolution and Versioning Easy


7. Introduces Schema Stitching


8. Makes Subscriptions Easy


9. Boosts Performance


10. Makes Querying easy with a Language
Simpli
f
ies back-end work
type Query {


getBook(id: Int!): Book


}


type Book {


id: Int!


author: String


price: Price!


stock: Stock


comments: [Comments]


}
MongoDB API call
XML file reading
REST API Call
SOAP API Call
Hide complexity
Simple resolvers
Flexible for front-end developers
Schema-
f
irst VS code-
f
irst...
Graph your Company
Classical architecture of your
company
ERP CRM PIM ECO WMS
API GATEWAY / API DEV PORTAL
APP 1 APP 2 APP 3 APP 4 APP X
How we built APIs so far
1. A way to access Data


2. A way to interact with an existing App


3. Designed by developers of the back-end systems
(represents their point of view on the world)
Spaghetti APIs
Over time, it creates a spaghetti of API endpoints, messy
documentation, and unbearable governance issues.
1. Each data structure change = API change


2. Each new feature in an app = API change


3. Each misunderstanding from back-end dev = API change
More problems
Developers implementing API have to understand data-
relations accross back-end systems. They have to learn
call-
fl
ow logics and data-structures of internal systems.


What is a client? What is a product?


"Give me all authors of bad reviews of products ordered
in the last month from warehouse in Hong Kong?"
How should we work
1. Start with usage. It's like UX for developers. Go front-
end
fi
rst approach. Needs create API.


2. Setup a schema governance team, not API governance
team.
GraphQL Graph Design tips
One of the most important things when designing
GraphQL schema is avoiding designs than will break with
changes in the future.
GraphQL Graph Design tips
Using Object types instead of simple types in
fi
elds
whenever possible. Avoid custom scalars.


type Duration is better than [date]
GraphQL Graph Design tips
Use descriptive, very precise Object Types. Do not try to
generalize. You can always add interfaces later.


GraphQLEuropeConference is better than Conference.
Some implementation
tips
Introspection
[SERVER]
Provides a GraphQL schema
Types system, speci
fi
c to the domain
[CLIENT]
Sends an introspection
query
Using GraphQL too !
[SERVER]
Returns a response
Introspetion schema is also supported
Authenti
f
ication
Should "login" be a mutation or a query?


Make a classical POST for authenti
fi
cation


Get a token the use it in all GraphQL operations as
a Header.
Authorizations
Network
GraphQL
Backend
Before GraphQL?
Inside resolvers?
In the back-end systems?
@GraphQLPortal - www.graphql-portal.com
Some facts
GraphQL is a real contract, strongly typed, between
applications, that can be veri
fi
ed by machines and o
ff
ers a
strict control over exposed datas.
Unlike REST which provides a list of endpoints, GraphQL
servers expose a graph of business objects that applications
can query.
Practical use cases
Backend REST API
as a Gateway
GraphQL DB
Practical use cases
Micro


service
in federation mode
Micro


service
Micro


service
Apps modernes
Mainframe
before / a
ft
er
GraphQL


Ecosystem
GraphQL Ecosystem
Apollo Client https://
www.apollographql.com/docs/react/


urql https://formidable.com/open-
source/urql/


graphql-react https://
www.npmjs.com/package/graphql-
react
CLIENTS
Apollo https://
www.apollographql.com/


Hasura https://hasura.io/


AWS AppSync https://
aws.amazon.com/appsync/
SERVERS
GraphQL Tools https://
www.graphql-tools.com/


GraphQL CodeGen https://
www.graphql-code-generator.com/
Visual Studio Code plugins


GraphiQL https://github.com/
graphql/graphiql
LIBS
EDITORS
GraphQL Portal https://
www.graphql-portal.com/


GATEWAY
Migration to GraphQL, A practical assessment: https://www.researchgate.net/
publication/330563526_Migrating_to_GraphQL_A_Practical_Assessment


Generating GraphQL Wrappers for REST APIs: https://arxiv.org/pdf/
1809.08319.pdf


Formalization of GraphQL Language: https://hal.archives-ouvertes.fr/
hal-02422532/document
Academic research
@GraphQLPortal - www.graphql-portal.com
GraphQL Portal
GraphQL Portal
GraphQL Portal
Where to
f
ind us?
Web : https://graphql-portal.com


Git : https://github.com/GraphQL-Portal/graphql-portal


Please, give us a ⭐ we give you love !
We can help
Consulting
&
expertise on GraphQL for your projects.


Development and integration, subcontracting.


Our expertise : GraphQL / APIs / Microservices


Our stack : Go / Node / Rust / ReactJS
{


"data": {


"result": "Thanks !"


},


"errors": []


}

apidays LIVE Hong Kong 2021 - GraphQL : Beyond APIs, graph your enterprise by Maxime Topolov, GraphQL Portal

  • 1.
  • 2.
  • 3.
    They are everywhereinside your company, your clients and partners...
  • 4.
  • 5.
  • 6.
    APIs are inyour microserivces
  • 7.
  • 8.
  • 10.
  • 11.
    APIs are nota new hot topic . 1991 CORBA 1993 RDA 1998 XML-RPC 1999 SOAP 2005 JSON-RPC 2015 GRAPHQL 2000 REST 2007 ODATA 2016 gRPC 1988 ONC RPC @GraphQLPortal - www.graphql-portal.com
  • 12.
  • 13.
  • 14.
    - can youmake me an endpoint with *just* a photo and a title? getProductBySKU(…) getProducts(…) getProductTitle(…) getProductPhotos(…) getProductMainPhoto(…) getListOfProductsWithPhoto(…) getListOfProductsAUserLikes(…) getListOfProductsIMightLikeButNotSu - OK! @GraphQLPortal - www.graphql-portal.com
  • 15.
  • 16.
    What I getfrom getServers(…) YAML JSON XML ? @GraphQLPortal - www.graphql-portal.com
  • 17.
  • 18.
    2012 Created in Facebookto support mobile apps. 2015 2018 Open-sourced by Facebook, fi rst draft of speci fi cations Governance moving from Facebook to GraphQL foundation Some story... @GraphQLPortal - www.graphql-portal.com
  • 19.
    But What isGraphQL ? "We don’t think of data in terms of resource URLs, secondary keys, or join tables; we think about it in terms of a graph of objects and the models we ultimately use in our apps like NSObjects or JSON." - Lee Byron, creator of GraphQL @GraphQLPortal - www.graphql-portal.com
  • 20.
    How it works? 1.Describe your data using type system de fi nition (schéma) 2. Ask what you need, executable de fi nition (query) 3. Get predictable results
  • 21.
    Types type Query { allMedia:[Media] firstMedia: Media getMedia(id: Int!): Media total: Int } union Media = Movie | Franchise type Movie { id: Int! title: Title genre: Genre } Returns a list of 'Media' This argument is required Union of two types This fi eld can't be null enum Genre { ADVENTURE COMEDY HORROR WEBINAR } This 'enum' is used for options
  • 24.
    Quick facts GraphQL isa strongly typed, hierachical protocol which de fi nes business objects of your enterprise. It o ff ers introspection and simpli fi es (removes?) versionning. @GraphQLPortal - www.graphql-portal.com
  • 25.
    10 Problems GraphQLSolves 1. Introduces proper Data Fetching 2. Solves Overfetching / Underfetching 3. Reduces waste of Network Requests 4. Brings Flexibility to the Static Nature of APIs 5. Makes Resource Deprecations Easy 6. Makes Evolution and Versioning Easy 7. Introduces Schema Stitching 8. Makes Subscriptions Easy 9. Boosts Performance 10. Makes Querying easy with a Language
  • 26.
    Simpli f ies back-end work typeQuery { getBook(id: Int!): Book } type Book { id: Int! author: String price: Price! stock: Stock comments: [Comments] } MongoDB API call XML file reading REST API Call SOAP API Call Hide complexity Simple resolvers
  • 27.
  • 28.
  • 29.
  • 30.
    Classical architecture ofyour company ERP CRM PIM ECO WMS API GATEWAY / API DEV PORTAL APP 1 APP 2 APP 3 APP 4 APP X
  • 31.
    How we builtAPIs so far 1. A way to access Data 2. A way to interact with an existing App 3. Designed by developers of the back-end systems (represents their point of view on the world)
  • 32.
    Spaghetti APIs Over time,it creates a spaghetti of API endpoints, messy documentation, and unbearable governance issues. 1. Each data structure change = API change 2. Each new feature in an app = API change 3. Each misunderstanding from back-end dev = API change
  • 33.
    More problems Developers implementingAPI have to understand data- relations accross back-end systems. They have to learn call- fl ow logics and data-structures of internal systems. What is a client? What is a product? "Give me all authors of bad reviews of products ordered in the last month from warehouse in Hong Kong?"
  • 34.
    How should wework 1. Start with usage. It's like UX for developers. Go front- end fi rst approach. Needs create API. 2. Setup a schema governance team, not API governance team.
  • 35.
    GraphQL Graph Designtips One of the most important things when designing GraphQL schema is avoiding designs than will break with changes in the future.
  • 36.
    GraphQL Graph Designtips Using Object types instead of simple types in fi elds whenever possible. Avoid custom scalars. type Duration is better than [date]
  • 37.
    GraphQL Graph Designtips Use descriptive, very precise Object Types. Do not try to generalize. You can always add interfaces later. GraphQLEuropeConference is better than Conference.
  • 38.
  • 39.
    Introspection [SERVER] Provides a GraphQLschema Types system, speci fi c to the domain [CLIENT] Sends an introspection query Using GraphQL too ! [SERVER] Returns a response Introspetion schema is also supported
  • 40.
    Authenti f ication Should "login" bea mutation or a query? Make a classical POST for authenti fi cation Get a token the use it in all GraphQL operations as a Header.
  • 41.
    Authorizations Network GraphQL Backend Before GraphQL? Inside resolvers? Inthe back-end systems? @GraphQLPortal - www.graphql-portal.com
  • 42.
    Some facts GraphQL isa real contract, strongly typed, between applications, that can be veri fi ed by machines and o ff ers a strict control over exposed datas. Unlike REST which provides a list of endpoints, GraphQL servers expose a graph of business objects that applications can query.
  • 43.
    Practical use cases BackendREST API as a Gateway GraphQL DB
  • 44.
    Practical use cases Micro service infederation mode Micro service Micro service Apps modernes Mainframe
  • 45.
  • 46.
  • 47.
    GraphQL Ecosystem Apollo Clienthttps:// www.apollographql.com/docs/react/ urql https://formidable.com/open- source/urql/ graphql-react https:// www.npmjs.com/package/graphql- react CLIENTS Apollo https:// www.apollographql.com/ Hasura https://hasura.io/ AWS AppSync https:// aws.amazon.com/appsync/ SERVERS GraphQL Tools https:// www.graphql-tools.com/ GraphQL CodeGen https:// www.graphql-code-generator.com/ Visual Studio Code plugins GraphiQL https://github.com/ graphql/graphiql LIBS EDITORS GraphQL Portal https:// www.graphql-portal.com/ GATEWAY
  • 48.
    Migration to GraphQL,A practical assessment: https://www.researchgate.net/ publication/330563526_Migrating_to_GraphQL_A_Practical_Assessment Generating GraphQL Wrappers for REST APIs: https://arxiv.org/pdf/ 1809.08319.pdf Formalization of GraphQL Language: https://hal.archives-ouvertes.fr/ hal-02422532/document Academic research @GraphQLPortal - www.graphql-portal.com
  • 49.
  • 50.
  • 51.
  • 52.
    Where to f ind us? Web: https://graphql-portal.com Git : https://github.com/GraphQL-Portal/graphql-portal Please, give us a ⭐ we give you love !
  • 53.
    We can help Consulting & expertiseon GraphQL for your projects. Development and integration, subcontracting. Our expertise : GraphQL / APIs / Microservices Our stack : Go / Node / Rust / ReactJS
  • 54.
    { "data": { "result": "Thanks!" }, "errors": [] }