Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Boost your API with GraphQL

What is GraphQL? How is the Java Ecosystem? What is the purpose of the MicroProfile GraphQL initative?

  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

Boost your API with GraphQL

  1. 1. Boost Your API with Running spqr and JNoSQL on Glassfish 5.1
  2. 2. What are we going to speak about?
  3. 3. A few words about @jefrajames Speaker me = SpeakerOf.setLastName(“James”) .setFirstName(“Jean-François”) .setBackground(Period.ofYears(33)) .setCompany(“Worldline”) .setLocation(“France”) .addSkill(“Software Architecture”, Year.parse (“1990”)) .addSkill(“Java”, Year.parse (“1997”));
  4. 4. A few requests about @theJiBz Let’s go to http://localhost:4000/ !
  5. 5. GraphQL – Not a silver bullet, again…
  6. 6. GraphQL – But a new way to design API ! Facebook introduced GraphQL at their Reactjs conference in 2015. GraphQL is a query language and runtime that we can use to build and expose APIs as a strongly-typed schema instead of hundreds of REST endpoints. Your clients see the schema. They write a query for what they want. They send it over and get back exactly the data they asked for and nothing more. Spec: https://facebook.github.io/graphql/draft/
  7. 7. GraphQL – A bit of history and context GraphQL (now) – Mobile era Schema as a contract Get only what you asked for High entry cost Graph oriented APIs RESTful API (00’) – Web era Loosely coupled systems Full usage of HTTP and browser features Loose data contract CRUD style APIs SOAP (90’) – Server era The big guns out: WS-Security, WS-AtomicTransaction, WS- ReliableMessaging … Tight coupling between server and client Heavy resources usage (big payload)
  8. 8. GraphQL – PROS / CONS Pros • Network performance improved • Lose coupling between client and server • Strong typing • Developer tooling Cons • Young ecosystem • N+1 to be solved • No full usage of HTTP • Partially complete response to be handled
  9. 9. GraphQL in the Java Ecosystem graphql-java schema initialization (DSL, API), query execution, error management Rel: 11.0, Oct 2018 graphql-java-tools schema-first Rel: 5.4.1, Nov 2018 spqr code-first Rel: 0.9.9, Dec 2018 graphql-java-servlet HTTP transport Rel: 7.2.0, Feb 2018 OR AND
  10. 10. Schema-first vs code-first Schema DSL written Java class Java class Java classSpecialized Java class GraphQLRootResolver GraphQLResolver<> GraphQLScalarType Etc … Annotated Java class Annotated Java class Annotated Java class Annotated Java class @GraphQLQuery @GraphQLMutation @GraphQLArgument @GraphQLInputField Etc …
  11. 11. From Java EE to Jakarta EE The follow up of Java EE The new brand name of the platform Transferred from Oracle to Eclipse Foundation in 2018 New governance model and specification process in place Started in 2016 In reaction to Java EE inertia Focus on Microservices Eclipse project Dynamic and innovative An incubator for Jakarta EE Previously Java EE Ref. Impl. Now an Eclipse Project 5.1 released in Jan 2019 Fisrt Jakarta EE version Java EE 8 certified More on Payara blog Eclipse top-level project About 40 subprojects TCK Specifications Implementations
  12. 12. What makes Jakarta EE different?
  13. 13. MicroProfile breaking news
  14. 14. Runtime support Runtime Provider Java SE 11 support Java EE Version MP Version GlassFish 5.1 Eclipse n 8 1.0 Payara 5.184 Payara y 8 2.0 TomEE 8.0 M1 TomiTribe y WebProfile 8 1.3 (partial) OpenLiberty IBM y 8 2.1 WildFly 15.0.1 Red Hat y 8 1.4 (Partial) Thorntail 2.3.0 Red Hat y y 2.1 KumuluzEE 3.1.0 Open Source y 8 1.2 Helidon Oracle ? none 1.2 SmallRye 2 Open Source ? none 2.1
  15. 15. • A Java framework that streamlines integration of NoSQL databases • A set of APIs to interact with NoSQL databases in a standard way • Support of Key-Value, Document, Column, Graph databases • The starting point for the first Jakarta EE new specification Introduction to JNoSQL
  16. 16. • Training exercise • In the context of MicroProfile GraphQL initiative • Also an opportunity: – To test GlassFish 5.1 – To test JNoSQL – To check portability on other application servers About the demo project-Why?
  17. 17. • Starting from the graphql-java-tutorial from Bojan Tomic • Switching from schema-first to code-first • Maximum CDI use, minimum graphql-servlet use • Plus JNoSQL in the picture • Available on GitHub About the demo project-How?
  18. 18. Coding a Query with spqr
  19. 19. Coding a Mutation with spqr
  20. 20. Coding a Resolver with spqr
  21. 21. • CDI beans everywhere: repositories, GraphQL classes, AuthContext • Generic CDI extension to create the schema • Plus a specific @GraphQLComponent CDI stereotype • Schema dynamically generated at application startup CDI integration
  22. 22. • DocumentCollectionManager CDI producer required • Use of JNoSQL template enabling select, insert and singleResult operations • JNoSQL Annotations on domain objects: @Entity, @Id, @Column, • Real simplification for the developer JNoSQL integration
  23. 23. • Started in Dec. 2018 • Creating a specification-based, easy to use, annotation-based API around CDI, JSON-P and JSON-B for GraphQL • The initial goal would be to create a code-first approach (similar to JAX-RS) • Following the "code-first approach", We propose to leverage existing solutions. The content proposed is heavily influenced by GraphQL SPQR. MicroProfile GraphQL-What for?
  24. 24. MicroProfile GraphQL-Who are we? Andy McCright (IBM) Phillip Kruger (Red Hat) Jean-Baptiste Roux (Worldline) Bojan Tomic (ServiceNow, spqr) Jean-François James (Worldline) Adam Anderson (IBM) You are welcome!
  25. 25. Thank you!