Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Minha api deve ser rest?

341 views

Published on

Na maioria das vezes, ao criar uma nova API, opta-se pelo Rest. Mas será que não tem outras opções?
Essa palestra aponta outras opções para o Rest como GraphQl, Falcor, gRPC, ou até mesmo criar o seu padrão

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Minha api deve ser rest?

  1. 1. MANDIC + RIVENDEL. ESPECIALISTAS EM CLOUDS. Minha API deve ser Rest?
  2. 2. Desenvolvedor @ezidio mandic.com.br Everton Tavares
  3. 3. #EspecialistaFaz
  4. 4.
  5. 5. https://graphql.org/
  6. 6. type Query { products: [Product] product(id:Int): [Product] } type Product { id: Int name: String tags: [String] price: Double category: Category } type Category { name: String } { products: { id name price category: { name } } }
  7. 7. type Query { products: [Product] product(id:Int): [Product] } type Product { id: Int name: String tags: [String] price: Double category: Category } type Category { name: String } { products: [ { “id”: 1, “name”: “Relogio Casio”, “price”: 270.4, “category”: { “name”: “Relogio” } }, { … } ] }
  8. 8. type Query { products: [Product] product(id:Int): [Product] } type Product { id: Int name: String tags: [String] price: Double category: Category } type Category { name: String } { product(id = 2): { id name } }
  9. 9. type Query { products: [Product] product(id:Int): [Product] } type Product { id: Int name: String tags: [String] price: Double category: Category } type Category { name: String } { product: { “id”: 1, “name”: “Relogio Casio” } }
  10. 10. type Mutation { update(id:Int, name:String): Product delete(id:Int): Boolean } mutation { update(id: 2, name: “Teste”): { id name } delete(id: 5) }
  11. 11. https://netflix.github.io/falcor/
  12. 12. var model = new falcor.Model({ source: new HttpDataSource(baseUrl + '/model.json') }); var jsonGraph = await model.get(["products", {from: 0, to:10}, ["id","name","price"]]);
  13. 13. /GET?paths=[“products[0..10][‘id’,’name’,’price’”]] { products: [ { “id”: 1, “name”: “Relogio Casio”, “price”: 270.4 }, { … } ] }
  14. 14. { categoryById: { "10": { product: "Relogios", done: false, prerequisites: [{ $type: "ref", value: ["todosById", 54] }] }, {...} }, categories: [{ $type: "ref", value: ["categoryById", 10] }, { ... }],
  15. 15. products: [ { id: 1 name: "Relogio Casio", price: 270.4 category: { $type: "ref", value: ["categoryById", 10] } }, {...} ] }
  16. 16. https://jrgql.github.io/
  17. 17. { “name”: “” } [ { “name”: “Relogio Casio” }, { “name”: “Relogio Rolex” }, { “name”: “Relogio Pirata” }, { … } ]
  18. 18. { “_id”: “”, “name”: “”, “price”: “” } [ { “_id”: 1, “name”: “Relogio Casio”, “price”: 270.4 }, { “_id”: 2, “name”: “Relogio Rolex”, “price”: 12000 }, { … } ]
  19. 19. { “_id”: “1”, “name”: “”, “price”: “” } [ { “_id”: 1, “name”: “Relogio Casio”, “price”: 270.4 } ]
  20. 20. { “_id”: “”, “name”: “”, “price<”: 500 “category”: { “name”: “” } } [ { “_id”: 1, “name”: “Relogio Casio”, “price”: 270.4, “category”: { “name”: “Relogio” } } ]
  21. 21. https://grpc.io/
  22. 22. service ProductService { rpc getProduct (ProductRequest) returns (Product) {} } message ProductRequest { int32 id = 1; } message ProductReply { int32 id = 1; string name = 2; double price = 3; }

×