- Data Providers
- PostgreSQL Data Provider (@exogee/graphweaver-mikroorm)
- MySQL Data Provider (@exogee/graphweaver-mikroorm)
- REST Data Provider (@exogee/graphweaver-rest)
- Xero Data Provider (@exogee/graphweaver-xero)
- Extending with Additional Data Providers
Graphweaver is designed to work with any number of data providers, allowing you to connect your GraphQL API to different data sources.
It provides support for multiple data providers out-of-the-box, including PostgreSQL, MySQL, REST, and Xero, giving you the flexibility to integrate with a wide range of systems.
And the architecture of Graphweaver allows for easy creation of data providers to interface with additional data sources as needed.
Data providers are implemented as a set of methods that define how to fetch, update, delete, and create data in a particular data source.
When defining a resolver, you can specify a data provider to use for that resolver.
The resolver then uses the methods provided by the BaseResolver to bind to the data provider and perform the requested operation on the data source.
Data providers can be used to implement caching, pagination, filtering, and other functionality specific to a particular data source. They can also be composed together to implement more complex behavior.
For example, you might have a query that fetches data from the database, and another data provider that fetches data from the REST API.
It can then compose these together to provide a unified API that fetches data from both sources, performs caching, and applies pagination and filtering as needed.
Let’s start by getting an overview of each of the current providers.
There are a number of build in data providers which offer different ways to connect Graphweaver with various data sources, including relational databases, RESTful APIs, and specific third-party services like Xero.
They provide a convenient and unified approach to integrating your data into your GraphQL API, allowing you to get on with building your app.
Let’s look at the built -in providers next.
PostgreSQL Data Provider (
This data provider allows you to connect your GraphQL API to a PostgreSQL database.
mikro-orm library, it enables seamless integration between BaseResolver and a PostgreSQL database.
You can perform various database operations, such as querying, inserting, updating, and deleting data, using GraphQL syntax.
MySQL Data Provider (
The MySQL data provider, which utilizes the mikro-orm library, enables seamless integration between BaseResolver and a MySQL database.
It provides automatic schema generation, handles the communication with the MySQL database, and allows you to perform database operations using GraphQL syntax.
REST Data Provider (
With the REST data provider, you can connect your GraphQL API to external RESTful APIs.
It provides a unified interface for consuming and interacting with RESTful services, allowing you to define custom REST endpoints, configure authentication, and handle request/response mapping.
Graphweaver abstracts away the complexities of interacting with RESTful APIs, simplifying the integration process.
Xero Data Provider (
The Xero data provider enables integration with the Xero accounting platform.
It handles the authentication and communication with the Xero API, allowing you to interact with accounting-related data such as invoices, transactions, and contacts.
By using the Xero data provider, you can seamlessly incorporate Xero functionality into your GraphQL API.
Extending with Additional Data Providers
Graphweaver’s modular architecture allows for easy extension with additional data providers.
If your application requires connectivity to a different data source, you can build a custom data provider and integrate with it.