2

When starting a new project, is it still best to use Rest API than GraphQL?

Most big enterprise companies use Rest API.

Comments
  • 1
    From what i know graphql is like saying what i want and getting it. An usual rest api is providing an document which promises which content is accessible where.
  • 3
    Actually Facebook, Braintree / PayPal, GitHub, and several other big ones already use GraphQL and recommend it over REST APIs. Microsoft Graph API also uses GraphQL-style requests where the API only returns the requested fields. I'd recommend using REST only if you need to quickly fetch one or two flat documents (i.e. without relationships), and nothing else
  • 2
    @ostream that's right
  • 2
    I'm working with GrapqhQl for almost a year now and I enjoy it. It takes a while until you wrap you head around it. But FieldResolver, Interfaces and Unions makes it really easy to extend existing endpoints without breaking backwards compatibility. It does not magically solve every problem you have with REST. And I feel you need a certain size of an API to justify the overhead.
  • 2
    As with almost everything, it depends.
    GraphQL is very nice when you want to avoid the hassle of having many REST endpoints to fetch data with multiple requests and then put it all together with some joined ids like from a relational databse.

    REST also tends to become hard to document, even with swagger. With GraphQL, the definition of the data is the formal documentation at the same time.

    And GraphQL gives you the flexibility to query only the data that you want. Which of course is only good if you actually need the flexibility. But sometimes it’s overkill and REST is simpler.
  • 1
    @Lensflare what's swagger equivalent for graphql?
  • 2
    @Devnergy There's no need for something like Swagger with GraphQL. A GraphQL API server knows all data types, input types, relationships, and operations it supports, therefore you can just run an introspection query to get all information about the API in real time (a.k.a. GraphQL schema).
  • 0
    @hitko exactly. or just look at the schema directly. It’s human readable.
  • 1
    I’d choose Graphql every time if it was up to me
Add Comment