3 ms·
GraphQL can be seen as a programming language to write API endpoints, which you can expose as HTTP endpoints in a RESTful way if you want (or use a single POST
by devit 5y ago
GraphQL can be seen as a programming language to write API endpoints, which you can expose as HTTP endpoints in a RESTful way if you want (or use a single POST endpoint, or use WebSockets).
In a traditional REST system you implement each API endpoint in a traditional programming language.
With GraphQL you first create a single GraphQL model and then write each API endpoint as a GraphQL query/mutation; often the code is in the source of the client apps and is extracted by the build system to generate the endpoints on the server.
It is also possible to let the client send arbitrary GraphQL at runtime to the server, although that's not recommended for security, performance and efficiency reasons.
In practice this means that if you change the client frontend to include different details in views (e.g. you decide to change a GraphQL-enabled HN so that the bio of the comment author is shown below every comment) then you only need to change the frontend and the GraphQL query (to include the extra data you need) and not the server backend code.