Closed jeangovil closed 7 months ago
This proposal aims to create a more readable and reusable syntax based on my experience as a full-stack developer. If you're interested, we can discuss these approaches further.
I think this more readable in terms of nested where, orWhere and other query operators.
const response = await unbody.gdoc.find({
where: {
title: 'Bitcoin' /* default behaviour = equals */,
orWhere: {
title: {like: 'Ethereum'}
}
},
nearText: ['cryptocurrency'],
select: ['title'], /* and { exclude: ['id'] }, this way we can get every field except excluded */
/* limit, pagination and other options */
})
This is more favorable for chain lovers :D.
const response = await unbody.gdoc
.find()
.where({title: 'Bitcoin'})
.orWhere({title: {like: 'Ethereum'}})
.nearText(['cryptocurrency'])
.select(['title'])
.exec()
// We can reuse gdoc object
const gdocListEntity = unbody.gdoc({fields: ['title'] /* and { exclude: ['id'] }, this way we can get every field except excluded */, /* limit, pagination and other options */})
const cryptoDocs = gdocListEntity .title('Bitcoin', 'Tron') .html('
const fiatDocs = gdocListEntity .title('United states dollar') .html('
const gdocSingleEntity = unbody.gdoc({ fields: ['title', 'html'] / and { exclude: ['id'] }, this way we can get every field except excluded /, limit: 1 / limit, pagination and other options /, }) const fiatDocs = gdocSingleEntity .id('XXXXXX') .get() // Replacement for exec
@miladazhdehnia Thanks for the proposal. I see we both see potential in Approach 2, and we think it's the best way forward.
A couple of things I'm wondering about:
Keen to hear your thoughts 🤔
As we've decided to move forward with the second proposed approach, the implementation will kick off from here
Description:
We require the development of a TypeScript client that interfaces with Unbody's GraphQL API. This client will strictly serve as a read-only interface, meaning no mutations are to be performed. It's important to note that Unbody utilizes Weaviate as its primary database. Consequently, all the operators, filters, and other functionalities will be consistent with those provided by Weaviate.
Objectives:
Potential Approaches:
1. Apollo Client Integration:
Example Usage:
2. Custom Client Development (Current Proposal):
Aim for a usage pattern that allows developers to send requests to Unbody API in an intuitive manner. For instance:
3. A combination of both?
While leveraging the powerful functionalities such as caching mechanism and local variables provided by Apollo, we can still design our own class base interface like approach 2.
Feedback and Collaboration:
We welcome contributions, ideas, and feedback from the community. If you have expertise or suggestions regarding these approaches or envision another potential solution, please share.