Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Boost your APIs with GraphQL 1.0

177 Aufrufe

Veröffentlicht am

Boost your APIs with GraphQL: Running SPQR and JNoSQL on Glassfish 5.1 by Jean-Francois James and Jean-Baptiste Roux

Veröffentlicht in: Technologie
  • Als Erste(r) kommentieren

Boost your APIs with GraphQL 1.0

  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 - Overview
  6. 6. GraphQL – A silver bullet ? ☺
  7. 7. 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/
  8. 8. GraphQL – A bit of history and context SOAP – Server to Server Data contract Strict (wsdl) Static (backend) Payload Heavy (XML, bindings, ports, services …) REST API – Web to Server Data contract Permissive (http) Static (backend) Payload Average (CRUD style APIs) GraphQL – Mobile to Server Data contract Strict (schema) Evolutive (gateway) Payload Small (Get Just What You Asked for)
  9. 9. GraphQL – PROS / CONS Pros • Network efficiency • Lose coupling between client and server • Strong typing • Live contract Cons • Young ecosystem • Gateway-side complexity • No full usage of HTTP • Client-side handling of partial responses
  10. 10. • Mobile/Multifront usage as the golden use case • Graph-oriented datasources • Unifying multiple datasources => « Soap is undead, REST is alive and GraphQL just born » GraphQL – To sum it up
  11. 11. GraphQL in the Java Ecosystem graphql-java schema initialization (DSL, API), query execution 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
  12. 12. 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 … schema-first code-first
  13. 13. From Java EE to Jakarta EE The follow up of Java EE The new brand name 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 First Jakarta EE version Java EE 8 certified More on Payara blog Eclipse top-level project About 40 subprojects TCK, Spec, Implementations From Oracle to Eclipse 13.5 million lines of code 95k files About 400 IP reviews
  14. 14. What makes Jakarta EE different?
  15. 15. • The first new Jakarta EE specification • To streamline integration of NoSQL databases • Supporting all database models: Key-Value, Document, Column, Graph, Hybrid • In a consistent way • Leveraging an existing solution: Moving forward Jakarta EE NoSQL
  16. 16. MicroProfile breaking news
  17. 17. Runtime support
  18. 18. • Training exercise, in the context of MicroProfile GraphQL initiative • Available on GitHub, detailed in a blog post • Also an opportunity: – To test GlassFish 5.1 – To check portability on other application servers – To test JNoSQL About the demo project-Why? Graph QL
  19. 19. • 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 About the demo project-How?
  20. 20. Coding a Query with spqr
  21. 21. Coding a Mutation with spqr
  22. 22. Coding a Resolver with spqr
  23. 23. More annotations with spqr
  24. 24. • 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
  25. 25. • 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
  26. 26. • 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?
  27. 27. 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!
  28. 28. • GraphQL specification: https://facebook.github.io/graphql/ • GraphQL foundation: https://foundation.graphql.org/ • graphql-java documentation: https://www.graphql-java.com/documentation/v11/ • Bojan Tomic tutorial: https://www.howtographql.com/graphql-java/0-introduction/ • Graphql-spqr github: https://github.com/leangen/graphql-spqr • Phillip Kruger membership project: https://github.com/phillip-kruger/membership • Phillip Kruger video: https://www.youtube.com/watch?v=TEF4qQzCXKI&feature=youtu.be • My demo project: https://github.com/jefrajames/spqrdemo • KumuluzEE GraphQL: https://github.com/kumuluz/kumuluzee-graphql/blob/master/README.md • Eclipse MicroProfile Sandbox: https://github.com/eclipse/microprofile-sandbox/tree/master/proposals/graphql References
  29. 29. Thank you!