Skip to content

GraphQL Inside

The interface to basebox uses GraphQL on top of https. Both are simple, flexible industry standards. No additional installations are required because the GraphQL server and an API are integral parts of basebox. Also, a unique GraphQL to SQL compiler is included. It ensures high performance and keeps developers from having to do SQL work.
It's Like Beaming:
GraphQL In, JSON Out, Skipping SQL.

Universal GraphQL API

Advantages of GraphQL Compared to REST:

  • Increased efficiency
    GraphQL allows clients to request only the data they need, reducing network overhead and improving performance.
  • Improved developer experience
    With GraphQL, developers have more control over the data they receive and can avoid over-fetching and under-fetching problems that can occur with REST.
  • Strong typing
    GraphQL's type system provides a powerful way to validate and document the API, which can improve developer productivity and reduce errors.
  • Better versioning and backwards compatibility
    Because clients can specify the exact data they need, changes to the API schema don't break client code.
  • Increased flexibility
    GraphQL allows for more flexible queries, simplifying client-side logic and reducing the number of API endpoints needed.
  • Easier to learn and use
    While REST can be complex and challenging to learn, GraphQL is often easier for developers to understand and use.

GraphQL Compiler

basebox' unique GraphQL compiler makes our GraphQL server exceptionally versatile.

The compiler is run during the installation or update of your project and converts your GraphQL schema file to a set of SQL template files for mutations and queries. basebox then uses these templates to translate GraphQL operations/requests into SQL queries, supporting automatic SQL joins to reduce database round trips to a minimum.

The benefits of this approach are:

  • Execution speed
    Avoid unnecessary database round trips through automatic SQL joins. This is a considerable performance boost since database I/O is usually the most expensive part of each request.
  • Implementation speed
    No need to write resolver functions for many queries and mutations.

In your query, you describe what information you want to get. basebox converts your GraphQL request to SQL, sends it to the database, and responds with GraphQL-compliant JSON.

Want to learn more about the benefits of having a GraphQL compiler? Read our Whitepaper:

WHITEPAPER

Performance Benefits

When serving API requests, database I/O is by far the most expensive (time-consuming) part so we can expect a significant performance gain by

  • avoiding unnecessary database hits altogether
  • JOINing queries whenever possible (see this article).

basebox' GraphQL compiler achieves both goals.

Additional benefits:

  • Reduced attack surface
    basebox minimizes the amount of custom code you need to write and maintain. In particular, you don't have to write resolvers anymore. Less code reduces the number of potential vulnerabilities that attackers could exploit.

  • Input validation
    The GraphQL to SQL compiler uses the strong typing of the GraphQL schema to validate input and ensure that the API only accepts valid data. This helps prevent injection attacks, a common type of security vulnerability.

  • Rate limiting
    Rate limiting prevents malicious clients from flooding the API with excessive requests.

  • Optimized SQL queries
    By generating optimized SQL queries, the compiler outperforms manually-written resolvers.

  • Simplicity
    The GraphQL to SQL compiler allows you to write GraphQL queries rather than SQL code, which is more intuitive and easier to comprehend.