Today i announce the DumbQL 1.0.6. This is a beta version because i want to add one big feature before calling it stable.
What's new in 1.0.6?
Multi-endpoint feature.
If you need to work with multiple GraphQL backends, in other libs you need to provide several instances of the library and get Angular DI errors (using multi: true in the providers doesn't really help with this issue).
I wanted to make that configurable — by the ng-add schematic and by a yaml file in your project.
How this works?
If you need more than one endpoint for your GQL backend in a project — like admin, main, products, etc — you create the endpoints.yml:
default_endpoint: 'main'
[endpoint]
name: main
url: backend/graphql
[endpoint]
name: products
url: backend/products
And the provider:
ts
provideDumbql({ multiEndpoints: true, endpointsConfig: './endpoints.yml' })
And in the component:
@Component({...})
export class MyCmp {
readonly data = query('main', query, opts...)
}
// endpointName is an optional parameter, but the library throws an error
// if you don't specify it when multiEndpoints is set to true in the config
The library links the string name identifier under the hood - url main makes a call to localhost/graphql, other endpoints go to whatever you configured.
Q: Does this spawn lib instances in the Angular DI container?
A: This is a harder question, but i have an answer for it. My plan is to make all providers a single provider function which spawns only one instance of the GraphQL service in the Angular DI container.
Q: Does this work on React/Vue?
A: I'm testing this on Angular first, and if the feature works correctly there, i'll adapt it for React and Vue.
I'm planning the release for next week, on Saturday or Sunday.
Top comments (0)