herbsjs / herbs2gql

Create a GraphQL endpoint based on Entities and Use Cases
MIT License
14 stars 21 forks source link

Herbarium - Use it to create mutations, queries and types #38

Closed dalssoft closed 2 years ago

dalssoft commented 2 years ago

With the new release of Herbarium, herbs2gql can generate mutations, queries and types using it.

Instead of custom files (ex: mutations.js, queries.js, types.js) on the project, using Herbarium will be much simpler since it is a standardized way to access Herbs objects.

Instead of: queries

const { usecase2query, defaultResolver } = require('@herbsjs/herbs2gql')
const { herbarium } = require('@herbsjs/herbarium')

const usecases = herbarium.usecases
    .findBy({ operation: [herbarium.crud.read, herbarium.crud.readAll] })
    .map(e => e.usecase)

const queries = usecases.map(usecase => usecase2query(usecase(), defaultResolver(usecase)))

/* Custom Queries */
// queries.push(require('./custom/getItems'))

module.exports = queries

it could be something like:

herbs2gql(herbarium)   // where `herbarium` constains all Herbs objects and its metadatas.
PedroMarquesFr2 commented 2 years ago

I'm working on it. @PedroMarquesFr

italojs commented 2 years ago

@jhomarolo could you update it with wip label, please?

PedroMarquesFr commented 2 years ago

I have just sent the pr herbsjs/herbs2gql#54, still working on the coverage, but can you check it and give some feedback? Is it on the right path?

@jhomarolo @italojs @dalssoft

PedroMarquesFr commented 2 years ago

documentation created @italojs herbsjs/herbsjs.github.io#132

herbsjs-robot commented 2 years ago

:tada: This issue has been resolved in version 2.2.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: