A Zayed Posted February 2, 2023 Share Posted February 2, 2023 We are excited to announce that the Invision Community GraphQL API is now available. This blog takes you through what GraphQL is and what makes it better than existing APIs present in Invision Community. It does get a bit technical, but you don't need to be a developer to appreciate how GraphQL will make life easier for those that do develop. What is GraphQL? GraphQL describes itself as a query language for APIs that gives clients the power to ask for precisely what is needed and nothing more. GraphQL was created by Facebook in 2012 and is now an open-source project governed by the GraphQL Foundation, which operates independently of Facebook. What makes GraphQL better than existing REST APIs? GraphQL has several advantages over the existing REST API present in Invision Community, and these include: Flexibility: GraphQL allows clients to request only the data they need, reducing over-fetching or under-fetching data. Getting data from a REST API often means receiving many fields and values you don't need to complete the operation you're creating. Versatility: GraphQL can query multiple databases or APIs, making it a more versatile solution than REST, which often requires multiple endpoints for multiple data types. Strong Typing: GraphQL has a robust type system, making it easier to understand the capabilities of an API and catch errors early in the development process. Better Performance: By allowing the client to request only the data it needs, GraphQL can improve the performance of an application compared to REST, which often returns more data than necessary. Easier to evolve: The schema-based nature of GraphQL allows for more straightforward and less-breaking changes to the API compared to REST. Let's look at an example You're building a dashboard that uses Invision Community data for your Node.js application that shows the latest topics, latest registered members and calendar events. With the REST API, you need to make three requests to get all the data you need. With GraphQL, you can fetch the exact data you need with a single request. Modern Web Development GraphQL is now the standard for modern web development, including building mobile apps. A modern web app has a "front-end" and a "back-end". The front-end refers to the user-facing part of the web application. The front-end is typically written in client-side languages such as HTML, CSS, and JavaScript and is responsible for rendering the user interface and handling user interactions. It communicates with the back-end to retrieve and display data. The back-end refers to the server-side part of the web application. The back-end is typically written in server-side languages such as PHP, and is responsible for performing business logic, managing data, and serving API responses to the front-end. Using GraphQL as the interface between the front-end and back-end, the development and deployment of each component can be done independently, improving the overall efficiency and scalability of the application. At Invision Community, we know that some clients use REST to pull data from Invision Community for use in bespoke web and mobile apps. So we hope you're even more excited about the possibilities with GraphQL. A list with all currently available queries, mutators and data types can be found in our developer documentation section. Extending Invision Community Functionality Of course, you also have full access to the GraphQL API in the Invision Community framework, so you can use GraphQL inside your controllers to run your queries, which has the advantage that you won't need to worry about future changes to the API. In addition, we have also created a GraphQL template plugin, which can be utilized inside templates to fetch any data. This is a more technology-heavy blog than usual. The main takeaway is that we continue to invest in ways to allow your Invision Community data to be used by your own applications. GraphQL makes that job a lot easier and much more efficient. Let me know if you have any questions!View the full post Link to comment Share on other sites More sharing options...
Recommended Posts