This document discusses lessons learned from implementing GraphQL APIs. It begins by describing some limitations of REST APIs, such as requiring multiple roundtrips to fetch nested data. GraphQL is introduced as an alternative that allows clients to specify exactly what data they need in a single request. The document then covers various GraphQL concepts like queries, mutations, and type systems. It also discusses best practices like using a schema-first approach, pagination support, and the DataLoader library to solve the N+1 problem. Testing GraphQL APIs and integrating with Relay are also briefly outlined. The overall message is that GraphQL is a good alternative to REST when clients have complex data needs.
GraphQL - Piękne API w Twojej Aplikacji - KrakowGraphAcademyMarcinStachniuk
Wszyscy znamy i tworzymy API RESTowe. Jednak to podejście ma swoje wady i ograniczenia. Dlatego Facebook stworzył GraphQL jako alternatywę. W mojej prezentacji przedstawię problemy RESTa oraz jak je rozwiązuje GraphQL. Pokażę składnię, jak projektować takie API oraz zalety i wady.
Building modular monoliths that could scale to microservices (only if they ne...David Gómez García
It’s easy these days to fall into the trap of starting to design your whole application with a microservices architecture…. Because, you know, that’s what everyone is doing. Aren't they?
But, are we considering the microservices architecture as a goal or as a means to a purpose?
In this talk, we will go back to the basics and see how DDD, CQRS and EventSourcing practices drive our application design and evolution so that we will start with a monolith. Still, we will have the ability to scale into microservices more or less easily when (and more importantly: if) we need to.
This is a presentation given by Dirk-Jan Rutten and Florentijn Hogerwerf at the React-Amsterdam Winter Event held on the 23rd of February 2017 (https://www.meetup.com/React-Amsterdam/events/237423993/).
GraphQL - Piękne API w Twojej Aplikacji - KrakowGraphAcademyMarcinStachniuk
Wszyscy znamy i tworzymy API RESTowe. Jednak to podejście ma swoje wady i ograniczenia. Dlatego Facebook stworzył GraphQL jako alternatywę. W mojej prezentacji przedstawię problemy RESTa oraz jak je rozwiązuje GraphQL. Pokażę składnię, jak projektować takie API oraz zalety i wady.
Building modular monoliths that could scale to microservices (only if they ne...David Gómez García
It’s easy these days to fall into the trap of starting to design your whole application with a microservices architecture…. Because, you know, that’s what everyone is doing. Aren't they?
But, are we considering the microservices architecture as a goal or as a means to a purpose?
In this talk, we will go back to the basics and see how DDD, CQRS and EventSourcing practices drive our application design and evolution so that we will start with a monolith. Still, we will have the ability to scale into microservices more or less easily when (and more importantly: if) we need to.
This is a presentation given by Dirk-Jan Rutten and Florentijn Hogerwerf at the React-Amsterdam Winter Event held on the 23rd of February 2017 (https://www.meetup.com/React-Amsterdam/events/237423993/).
Domain Driven Design and Hexagonal Architecture with RailsDeclan Whelan
You know that Domain Driven Design, Hexagonal Architecture, and the Single Responsibility Principle are important but it’s hard to know how to best apply them to Rails applications. Following the path of least-resistance will get you in trouble. In this session you will learn a way out of the “fat model, skinny controller” hell. You will leave with a roadmap to guide your design based on concepts from Domain Driven Design and Hexagonal Architecture.
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) ExtensionVMware Tanzu
GemFire GraphQL (G2QL) is an extension that adds a new query language for your Apache Geode™ or Pivotal GemFire clusters allowing developers to build web and mobile applications using any standard GraphQL libraries. G2QL provides an out-of-the-box experience by defining GraphQL schema through introspection. It can be deployed to any GemFire cluster and serves a GraphQL endpoint from an embedded jetty server, just like GemFire’s REST endpoint.
We will be demoing G2QL using a sample application that can read and write data to GemFire and share data between applications built using GemFire client APIs, showing you:
- How to use GraphQL to query and mutate data in GemFire
- How to use open-source GraphQL library to build web and mobile applications using GemFire
- How to use GraphQL to deal with object graphs
- How G2QL can simplify their overall architecture
Presenters : Sai Boorlagadda, Staff Software Engineer & Jagdish Mirani, Pivotal
Finding the right stuff, an intro to Elasticsearch (at Rug::B) Michael Reinsch
Searching through a dataset can provide quite interesting challenges, especially when natural languages are involved. Elasticsearch is a very powerful yet also at times quite complex solution.
In this talk I'll give an intro on using Elasticsearch from within Ruby/Rails, discussing some of the general principles, starting with a simple example and then expanding into more complex topics such as multi-language search, search on data from multiple different objects, integration testing and production use.
WCF Data Services (formerly known as "ADO.NET Data Services") is a component of the .NET Framework that enables you to create services that use the Open Data Protocol (OData) to expose and consume data over the Web or intranet by using the semantics of representational state transfer (REST). OData exposes data as resources that are addressable by URIs. Data is accessed and changed by using standard HTTP verbs of GET, PUT, POST, and DELETE. OData uses the entity-relationship conventions of the Entity Data Model to expose resources as sets of entities that are related by associations.
Like Java Server Pages (JSP), GSP supports the concept of custom tag libraries. Unlike JSP, Grails' tag library mechanism is simple, elegant and completely reloadable at runtime.
Typed? Dynamic? Both! Cross-platform DSLs in C#Vagif Abilov
In this session we will demonstrate how to design DSLs in C# that expose both typed and dynamic API. The advantage of such hybrid APIs is that they can take advantage of dynamic C# features, but offer a fallback for .NET platforms that lack DLR support and developers not willing to abandon the convenience of compile-time code validation. We will show how to ensure code sharing between typed and dynamic versions, and how to package and publish library files so they can be consumed on variety of .NET platforms, including iOS and Android.
GraphQL - when REST API is to less - lessons learnedMarcinStachniuk
We all know the REST architectural style to define a good API for your applications. However, REST has its disadvantages and constraints. That’s why Facebook developed GraphQL as an alternative.
In my talk, I will present you some REST constraints and how GraphQL solves them. I will talk about how we implemented GraphQL in our application and why.
Get to know our successes… and failures from the first row.
Domain Driven Design and Hexagonal Architecture with RailsDeclan Whelan
You know that Domain Driven Design, Hexagonal Architecture, and the Single Responsibility Principle are important but it’s hard to know how to best apply them to Rails applications. Following the path of least-resistance will get you in trouble. In this session you will learn a way out of the “fat model, skinny controller” hell. You will leave with a roadmap to guide your design based on concepts from Domain Driven Design and Hexagonal Architecture.
Simplify Access to Data from Pivotal GemFire Using the GraphQL (G2QL) ExtensionVMware Tanzu
GemFire GraphQL (G2QL) is an extension that adds a new query language for your Apache Geode™ or Pivotal GemFire clusters allowing developers to build web and mobile applications using any standard GraphQL libraries. G2QL provides an out-of-the-box experience by defining GraphQL schema through introspection. It can be deployed to any GemFire cluster and serves a GraphQL endpoint from an embedded jetty server, just like GemFire’s REST endpoint.
We will be demoing G2QL using a sample application that can read and write data to GemFire and share data between applications built using GemFire client APIs, showing you:
- How to use GraphQL to query and mutate data in GemFire
- How to use open-source GraphQL library to build web and mobile applications using GemFire
- How to use GraphQL to deal with object graphs
- How G2QL can simplify their overall architecture
Presenters : Sai Boorlagadda, Staff Software Engineer & Jagdish Mirani, Pivotal
Finding the right stuff, an intro to Elasticsearch (at Rug::B) Michael Reinsch
Searching through a dataset can provide quite interesting challenges, especially when natural languages are involved. Elasticsearch is a very powerful yet also at times quite complex solution.
In this talk I'll give an intro on using Elasticsearch from within Ruby/Rails, discussing some of the general principles, starting with a simple example and then expanding into more complex topics such as multi-language search, search on data from multiple different objects, integration testing and production use.
WCF Data Services (formerly known as "ADO.NET Data Services") is a component of the .NET Framework that enables you to create services that use the Open Data Protocol (OData) to expose and consume data over the Web or intranet by using the semantics of representational state transfer (REST). OData exposes data as resources that are addressable by URIs. Data is accessed and changed by using standard HTTP verbs of GET, PUT, POST, and DELETE. OData uses the entity-relationship conventions of the Entity Data Model to expose resources as sets of entities that are related by associations.
Like Java Server Pages (JSP), GSP supports the concept of custom tag libraries. Unlike JSP, Grails' tag library mechanism is simple, elegant and completely reloadable at runtime.
Typed? Dynamic? Both! Cross-platform DSLs in C#Vagif Abilov
In this session we will demonstrate how to design DSLs in C# that expose both typed and dynamic API. The advantage of such hybrid APIs is that they can take advantage of dynamic C# features, but offer a fallback for .NET platforms that lack DLR support and developers not willing to abandon the convenience of compile-time code validation. We will show how to ensure code sharing between typed and dynamic versions, and how to package and publish library files so they can be consumed on variety of .NET platforms, including iOS and Android.
GraphQL - when REST API is to less - lessons learnedMarcinStachniuk
We all know the REST architectural style to define a good API for your applications. However, REST has its disadvantages and constraints. That’s why Facebook developed GraphQL as an alternative.
In my talk, I will present you some REST constraints and how GraphQL solves them. I will talk about how we implemented GraphQL in our application and why.
Get to know our successes… and failures from the first row.
[DevCrowd] GraphQL - gdy API RESTowe to za małoMarcinStachniuk
Slajdy z konferencji DevCrowd
Wszyscy znamy architekturę REST do definiowania API naszych aplikacji. Jednak REST ma swoje wady i ograniczenia. To dlatego Facebook stworzył GraphQL jako alternatywę. W mojej prezentacji przedstawię ograniczenia RESTa i jak je rozwiązuje GraphQL. Pokażę składnię, zalety jak i wady. Będzie też o tym jak zaimplementować GraphQL w Javie oraz co jeszcze warto o nim wiedzieć.
MongoDB World 2019: Building a GraphQL API with MongoDB, Prisma, & TypeScriptMongoDB
Originally developed by Facebook, GraphQL is taking over the industry and replaces REST as an API standard. Learn how it works and build your own GraphQL API with Prisma, MongoDB & TypeScript. Prisma auto-generates a MonogDB client to connect your GraphQL resolvers with MongoDB in a type-safe way.
Slajdy z konferencji Confitura 2019.
Wszyscy znamy podejście REST do definiowania API naszych aplikacji. Jednak REST ma swoje wady i ograniczenia. To dla tego Facebook stworzył GraphQL jako alternatywę. W mojej prezentacji przedstawię ograniczenia RESTa i jak je rozwiązuje GraphQL. Pokażę składnię, zalety jak i wady. Będzie też jak zaimplementować GraphQL w Javie oraz co jeszcze warto o nim wiedzieć.
BruJUG Brussels GraphQL when RESR API is to less - lessons learnedMarcinStachniuk
We all know the REST architectural style to define a good API for your applications. However, REST has its disadvantages and constraints. That’s why Facebook developed GraphQL as an alternative.
In my talk, I will present you some REST constraints and how GraphQL solves them. I will talk about how we implemented GraphQL in our application and why.
Get to know our successes… and failures from the first row.
Moje slajdy z prezentacji na GraphQL Wroclaw #3 https://www.meetup.com/GraphQL-Wroclaw/events/261828347/
Większość prezentacji dotyczących GraphQL opowiada o JavaSkryptowych narzędziach, natomiast mało kto mówi o tym jak korzystać z GraphQL w Javie. Prezentacja będzie o tym, jak sprawić aby nasz backendowy, Javowy serwer korzystał z GraphQL. Będzie o możliwych podejściach w implementacji, dobrych praktykach i 4-letnim doświadczeniu z GraphQL na produkcji.
Slides from presentation, I've made on the BuildStuff LT 2018. Here I'm talking about issues, many people have found when using RESTful APIs and how GraphQL addresses them. Also I'm trying to cover the tradeoffs made by the standard, solutions proposed by different implementations and some ideas for the future.
SQL for Web APIs - Simplifying Data Access for API ConsumersJerod Johnson
From Nordic APIs Platform Summit 2019 - Stockholm, Sweden
As the data world evolves, businesses are moving more of their data out of databases and into SaaS applications. Despite the migration, SQL remains a ubiquitous language for data access, so much so that many SaaS applications and non-relational cloud data stores support SQL endpoints in their APIs. While these endpoints allow users to leverage SQL queries to easily request data, there are still costly challenges to overcome when it comes to processing and managing the returned data.
In this presentation, we'll showcase popular APIs that offer SQL endpoints, explore the benefits of providing customers SQL access, and cover how standards-based drivers enable SaaS integration and self-service data access through SQL.
Similar to GraphQL - when REST API is not enough - lessons learned (20)
Do you know how Continuous Delivery of Java Open Source libraries looks? How big is your release overhead? Do you update release notes and include contributors manually? How do you handle versioning? Do you use semantic versioning?
During this workshop, you will learn how to set up Continuous Delivery for your library. You’ll never have to manually release new versions again. We will use the following tools: GitHub, TravisCI, Bintray, Maven Central. We will glue everything using Shipkit.org - a project born from Mockito (and still used there). You’ll additionally learn SerVer.
This workshop is mostly for Java open source and Gradle plugins developers. We will use a library prepared especially for this training, so no worries if you don’t have your own open source project (yet).
Prerequisites: GitHub account, Java & Gradle basics.
Continuous delivery w projekcie open source - Marcin StachniukMarcinStachniuk
Opublikowałeś swój projekt jako Open Source i zastanawiasz się co dalej? Jaki jest twój następny krok? Podczas prezentacji przedstawię, w jaki sposób można zbudować darmowy pipeline continuous delivery dla twojego projektu. Praca wtedy stanie się od razu przyjemniejsza i będzie można zapomnieć o nudnych i powtarzalnych czynnościach. Dodatkowo podpowiem jak zadbać o swój projekt, aby wyglądał profesjonalnie.
Prezentacja na targi Kariera IT 2017 we Wrocławiu.
Liquibase - Zarządzanie zmianami w relacyjnych bazach danychMarcinStachniuk
Prezentacja wygłoszona na Wrocławskim JUGu 30 września 2015. Prezentacja opisuje w jaki sposób można zarządzać zmianami w relacyjnych bazach danych i jak ten problem rozwiązuje Liquibase.
Podstawy tworzenia gier w J2ME, dla początkujących adeptów sztuki programowaniaMarcinStachniuk
Prezentacja pokazująca podstawy tworzenia gier w technologii J2ME z wykorzystaniem niskopoziomowego API.
Prezentacja dla osób zaczynających przygodę z programowaniem.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
Here is something new! In our next Connector Corner webinar, we will demonstrate how you can use a single workflow to:
Create a campaign using Mailchimp with merge tags/fields
Send an interactive Slack channel message (using buttons)
Have the message received by managers and peers along with a test email for review
But there’s more:
In a second workflow supporting the same use case, you’ll see:
Your campaign sent to target colleagues for approval
If the “Approve” button is clicked, a Jira/Zendesk ticket is created for the marketing design team
But—if the “Reject” button is pushed, colleagues will be alerted via Slack message
Join us to learn more about this new, human-in-the-loop capability, brought to you by Integration Service connectors.
And...
Speakers:
Akshay Agnihotri, Product Manager
Charlie Greenberg, Host
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
8. Different clients - different needs
/web /iphone /android /tv
Application
Web iPhone Android TV
9. Different clients - different needs
/web /iphone /android /tv
Application
Web iPhone Android TV
Content-Type: application/vnd.myawesomecorporation.com+v1+web+json
iphone
android
tv
10. Different clients - different needs
/web /iphone /android /tv
Application
Web iPhone Android TV
Content-Type: application/vnd.myawesomecorporation.com+v1+web+json
iphone
android
tv
14. GraphQL
● Graph Query Language
● Published by Facebook in 2015
● Growth from Facebook Graph API
● Reference implementation in JavaScript
● First version of Java Library: 18 Jul 2015
● First usage: 21 Sep 2015
15. Lessons Learned #1
Never add a library to your project
few days after init release
● No community
● A lot of bugs
● Bad documentation
● Strict following reference implementation and specification
16. GraphQL main concepts
● One endpoint for all operations
● Always define in request what you need
● Queries, Mutations and Subscription
● Defined by schema (type system)
● Good developer tools
17. GraphQL Simple API
GET /customers/2?fields=id,name,email
type Customer {
id: ID!
name: String!
email: String!
}
type Query {
customer(id: String!): Customer!
}
{
"data": {
"customer": {
"id": "2",
"name": "name",
"email": "a@b.com"
}
}
}
{
customer(id: "2") {
id
name
email
}
}
18. GraphQL Simple API
GET /customers/2?fields=id,name,email,company(id,name)
type Customer {
id: ID!
name: String!
email: String!
company: Company
}
type Company {
id: ID!
name: String!
website: String!
}
type Query {
customer(id: String!): Customer!
}
{
"data": {
"customer": {
"id": "2",
"name": "name",
"email": "a@b.com",
"company": {
"id": "211",
"name": "Company Corp."
}
}
}
}
{
customer(id: "2") {
id
name
email
company {
id
name
}
}
}
19. GraphQL Simple API
GET /customers/2?fields=id,name,email,orders(id,status)
type Customer {
id: ID!
name: String!
email: String!
company: Company
orders: [Order]
}
type Order {
id: ID!
status: Status
}
type Status {
NEW, CANCELED, DONE
}
{
"data": {
"customer": {
"id": "22",
"name": "name",
"orders": [
{
"id": "55",
"status": "NEW"
},
{
"id": "66",
"status": "DONE"
}
]
} } }
{
customer(id: "2") {
id
name
orders {
id
status
}
}
}
20. How to implement DataFetcher for queries
GET /customers/2?fields=id,name,email,orders(id,status)
{
customer(id: "2") {
id
name
orders {
id
status
}
}
}
@Component
public class CustomerFetcher extends PropertyDataFetcher<Customer> {
@Autowired
private CustomerService customerService;
public CustomerFetcher() {
super("customer");
}
@Override
public Customer get(DataFetchingEnvironment environment) {
String id = environment.getArgument("id");
return customerService.getCustomerById(id);
}
}
21. How to implement DataFetcher for queries
GET /customers/2?fields=id,name,email,orders(id,status)
{
customer(id: "2") {
id
name
orders {
id
status
}
}
}
public class Customer {
private String id;
private String name;
private String email; // getters are not required
}
public class OrderDataFetcher extends PropertyDataFetcher<List<Order>> {
@Override
public List<Order> get(DataFetchingEnvironment environment) {
Customer source = environment.getSource();
String customerId = source.getId();
return orderService.getOrdersByCustomerId(customerId);
}
}
22. How to implement DataFetcher for queries
@Override
public Customer get(DataFetchingEnvironment environment) {
Object source = environment.getSource();
Object root = environment.getRoot();
if (source instanceof Customer) {
// ...
} else if (...) {
// ...
}
// ...
}
24. How to implement DataFetcher for mutations
POST /customers
mutation {
createCustomer(input: {
name: "MyName"
email: "me@me.com"
clientMutationId: "123"
}) {
customer {
id
}
clientMutationId
}
}
@Override
public CreateCustomerPayload get(DataFetchingEnvironment environment) {
Map<String, Object> input = environment.getArgument("input");
String name = (String) input.get("name");
String email = (String) input.get("email");
String clientMutationId = (String) input.get("clientMutationId");
Customer customer = customerService.create(name, email);
return new CreateCustomerPayload(customer, clientMutationId);
}
25. Abstraction over GraphQL Java
Our abstraction
Data Fetcher 2
Pagination
Inputs mapping to objects
...
Data Fetcher 1 Data Fetcher N...
26. Lessons Learned #2
Abstraction is not good if you don’t understand
how it works under the hood
● A lot of copy paste errors
● Bad design of our API
● Let’s think in graphs and NOT in endpoints / resources / entities / DTO
27. GraphQL can do more!
● Aliases
● Fragments
● Interfaces
● Unions
● ...
34. Lessons Learned #3
Schema First Approach is better
Code First approach:
● Hard to maintain
● It was the only way at the
beginning to define a schema
● No possibility to mix both
● No easy way to migrate to
Schema First - technical debt
Schema First Approach:
● Easy to maintain and
understand
● Help organise work
● Demo schema definition only
in 54 + 23 lines, instead of 173
lines
36. Lessons Learned #4
GraphQL is not full query language
● More flexibility
● Less common conventions
● Dgraph.io created GraphQL+- extension with filtering, regular
expressions, i18n, equal/greater/less…
37. Assumptions enforced by Relay
● All returned types need to implement
Node interface
interface Node {
id: ID!
}● All IDs needs to be unique in whole
graph
● ID should be base64
● For pagination use PageInfo
type PageInfo {
hasNextPage: Boolean
hasPreviousPage: Boolean
# optional:
startCursor: String
endCursor: String
}
43. Summary
GraphQL:
● Nice alternative to REST
● It can be used together with REST
● Good integration with Relay / ReactJS
● You get exactly what you want to get
● Good for API with different clients
● Good to use on top of existing API
● Self documented
● Easy testing