Advertisement
Advertisement

More Related Content

Similar to Managing GraphQL servers with AWS Fargate & Prisma Cloud(20)

Advertisement
Advertisement

Managing GraphQL servers with AWS Fargate & Prisma Cloud

  1. Managing GraphQL servers with AWS Fargate & Prisma Cloud @nikolasburk
  2. Nikolas Burk Based in Berlin Developer at @prisma @nikolasburk@nikolasburk
  3. GraphQL introduction Core mechanis of a GraphQL server Building GraphQL servers with Prisma Managing GraphQL servers with AWS Fargate & Prisma Cloud Agenda 1 2 3 4 @nikolasburk
  4. Introduction @nikolasburk
  5. What is GraphQL? New API standard developed by Facebook Specficiation for type system & query language Core primitives: Query, Mutation & Subscription
  6. Why use GraphQL? Strongly typed schema for your API Query exactly the data you need Rich ecosystem, smooth workflows and great community
  7. query { user(id: “user123”) { name posts { title } } } HTTP POST { "data" :{ "user": { "name": "Sarah", "posts": [ { "title": "Join us for GraphQL Europe" }, { "title": "GraphQL is the future of APIs" }, ] } } }
  8. Learn more 💡 https://blog.graph.cool/b60cfa683511 Top 5 Reasons To Use GraphQL https://www.howtographql.com/basics/0-introduction/ GraphQL Introduction @nikolasburk
  9. Core mechanics of a GraphQL server @nikolasburk
  10. Structure: The GraphQL Schema Behaviour: Resolver functions Setup: Engine, Server/Network, Middlewares… 3 parts of a GraphQL server 1 2 3
  11. 1 The GraphQL Schema Strongly typed & written in GraphQL Schema Definition Language (SDL) Defines API capabilities (contract for client-server communication) Special root types: Query, Mutation, Subscription
  12. Example: Hello World type Query { hello: String! } GRAPHQL SCHEMA query { hello } QUERY { “hello”: “Hello World” } RESPONSE
  13. type User { id: ID! name: String! } type Query { user(id: ID!): User users: [User!]! } type Mutation { createUser(name: String!): User! updateUser(id: ID!, anme: String!): User deleteUser(id: ID!): User } Example: CRUD for User type
  14. type User { id: ID! name: String! } type Query { user(id: ID!): User users: [User!]! } type Mutation { createUser(name: String!): User! updateUser(id: ID!, anme: String!): User deleteUser(id: ID!): User } query { user(id: “user123”) { name } } { “user”: { “name”: “Sarah” } } Example: CRUD for User type
  15. 2 Resolver functions Concrete implementation of the API One resolver function per field in SDL schema Query execution: Invoke resolvers for all fields in query
  16. type Query { hello: String! } GRAPHQL SCHEMA const resolvers = { Query: { hello: () => `Hello World` } } RESOLVER FUNCTIONS Example: Hello World
  17. GRAPHQL SCHEMA type Query { user(id: ID!): User users: [User!]! } type Mutation { createUser(name: String!): User! updateUser(id: ID!, anme: String!): User deleteUser(id: ID!): User } type User { id: ID! name: String! } RESOLVER FUNCTIONS const resolvers = { Query: { user: (root, args) => db.getUser(args.id), users: () => db.getUsers() }, Mutation: { createUser: (root, args) => db.createUser(args.name), updateUser: (root, args) => db.updateUser(args.id, args.name), deleteUser: (root, args) => db.deleteUser(args.id), }, User: { id: (root) => root.id, name: (root) => root.name } } Example: CRUD for User type
  18. 3 Setup "GraphQL engine" to orchestrate resolver invocations Network layer based on "graphql-yoga" (network configuration: port, endpoints, CORS … ) Middleware (analytics, logging, crash reporting … )
  19. import { GraphQLServer } from 'graphql-yoga' const typeDefs = ` type Query { hello: String! } ` const resolvers = { Query: { hello: () => `Hello World` } } const server = new GraphQLServer({ typeDefs, resolvers }) server.start(() => console.log(`Server is running on port 4000`)) RESOLVERS SCHEMA SETUP …putting it all together
  20. import { GraphQLServer } from 'graphql-yoga' const typeDefs = ` type Query { hello: String! } ` const resolvers = { Query: { hello: () => `Hello World` } } const server = new GraphQLServer({ typeDefs, resolvers }) server.start(() => console.log(`Server is running on port 4000`)) RESOLVERS SCHEMA SETUP …putting it all together
  21. import { GraphQLServer } from 'graphql-yoga' const typeDefs = ` type Query { hello: String! } ` const resolvers = { Query: { hello: () => `Hello World` } } const server = new GraphQLServer({ typeDefs, resolvers }) server.start(() => console.log(`Server is running on port 4000`)) RESOLVERS SCHEMA SETUP …putting it all together
  22. import { GraphQLServer } from 'graphql-yoga' const typeDefs = ` type Query { hello: String! } ` const resolvers = { Query: { hello: () => `Hello World` } } const server = new GraphQLServer({ typeDefs, resolvers }) server.start(() => console.log(`Server is running on port 4000`)) RESOLVERS SCHEMA SETUP …putting it all together
  23. Learn more 💡 https://blog.graph.cool/ac5e2950214e GraphQL Server Basics - The Schema https://www.howtographql.com/graphql-js/0-introduction/ GraphQL Server Tutorial @nikolasburk
  24. 🍿 Demo 1
  25. Building GraphQL servers with Prisma @nikolasburk
  26. Architecture Client API Server DatabasePrisma (based on Docker)
  27. DB-agnostic Data Access Layer (think ORM) Prisma turns your DB into a GraphQL API Your API server delegates queries to Prisma Prisma
  28. Learn more 💡 https://www/prisma.io/docs/quickstart Prisma Quickstart https://www.prisma.io/docs/reference/-apohpae9ju What is Prisma? @nikolasburk
  29. 🍿 Demo 2
  30. Managing GraphQL servers with AWS Fargate & Prisma Cloud @nikolasburk
  31. Web app to manage Prisma servers OSS Prisma & Prisma Cloud OSS Prisma = Abstraction Prisma Cloud = Workflows Prisma Cloud
  32. Learn more 💡 https://www.prisma.io/docs/tutorials/-joofei3ahd Deploy a Prisma server to AWS Fargate @nikolasburk
  33. 🍿 Demo 3
  34. Thank you 🙏 @nikolasburk@nikolasburk
Advertisement