Buy @ Amazon

Search This Blog

August 16, 2020

GraphQL FAQs


  1. Is GraphQL a DB? No! For graphDB checkout options like ArangoDB, OrientDB, Neoj, DGraph etc.

  2. Is GraphQL an interface to Graph DB? No! Think of it as a parallel to REST or SOAP way of exposing your APIs.

  3. Is GraphQL a replacement for REST? It may or may not depending on your business context.

  4. Can GraphQL co-exist with REST? Yes!, it sure can.

  5. Does GraphQL have good tooling support? There is good tooling support to get you onboarded and get going. There needs to be more though, say for example, support in defining your GraphQL schema.

  6. Has GraphQL got supported libraries in my language platform? Checkout https://graphql.org/code/ for list of libraries by language, for client-side support and server-side runtime support. And there are also much more goodies in there to explore and experiment with.

  7. Is there a big picture view of GraphQL landscape that I can see? Do checkout https://landscape.graphql.org/.

  8. Is GraphQL better than REST? That depends on the metrics you are looking out for.

  9. Okay, how does GraphQL shine better over REST? Some of the things include,

    1. Simpler API grammar if that pleases you, GET for read operations and POST for write operations.

    2. Adopts better with need for "Evolutionary APIs", mitigating the need for upfront thought on "Versioning APIs" as contracts. This is a super cool thing that this Agile world of development desperately needs to fight its competitors.

    3. API to ask what you want explicitly and get just that and no more. This could mean better performance on both client-side and server-side.

  10. What are the areas where REST shines over GraphQL? Some of the areas include,

    1. Unlike GraphQL, REST needs no additional infrastructure. REST is fluent API that best leverages HTTP protocol to gain maximum mileage. Bow to Roy Fielding for this!

    2. Caching comes for free and easy with REST. This is relatively harder and needs additional infrastructure.

    3. Good part of the world has gone past heavy-weight SOAP to adopting light-weight REST which is the defacto-standard for the entire toolbelt and ecosystem. GraphQL made its presence known resulting in increased "reference-implementation" libraries across language platforms. How this will unfold beyond this hype is yet to be witnessed..

  11. Constructing and maintaining the GraphQL Schema on the server-side with Express.js isn't looking easy for me. As the graphql schema size grows, fitting the schema within the back-ticks is maintenance pain for me. There is not expand/collapse of parts of stringified schema after all. Also, absence of intellisense for this stringified piece is a pain in refactoring schema definitions. Am I missing something? You are not alone here, is the only consolation I have for you at this juncture. I have the same pain and I alleviate it a bit by modularizing the schema to separate files and use string interpolation in the schema definition file. This alleviates some of the said pain points. But absence of intellisense during development is a pain in the back making me question if I'm witnessing "graphql pop-culture" or genuine strengths of it. I'm still experimenting and so this opinion may change and will be updated as I learn.
  12. Not all fields are relevant to all consumers of my API either for the reasons of security or business context. Take for instance, the password field in the User isn't required beyond the signup or password change functionality even for the very user and is breach of security for others to get even the hash of it in their context in fetching Users. Is there a way I can customize this behavior in GraphQL? That's a great question and I'm yet to figure it out. But do hope there is a way out for this, as this is a very basic criteria, after all. My reference API would be Github API, for this.
  13. Given that the API's exposes the fields, would it end-up being too rigid for Public APIs where you don't own the client/consumer app? Sorry, I don't have an answer for this one. Github can't be taken as a reference case for this, so I'd have to look out for a business case likely in the B2B space where different clients demand different needs from an API.
  14. I see a myriad of ways to building GraphQL APIs for consumption and unsure how one is different from the other and if I am missing something. Am I? As I see it, you will still be an early adopter of GraphQL, given the state of evolution that it is in today. Thus, your choice of platform could determine if you are taking SDL-first or code-first approach to development. And then your choice of runtime, could determine how you design and build your schema, how you implement your resolvers (if you know what it is in the graphql context), etc. Doing a PoC with some of the popular options will help you determine what best fits your team context.
More would be added as I experiment with GraphQL and have more conversations in this space. Stay tuned..

No comments:

Post a Comment

Like it or hate it, feel free to share your feedback. Cheers!