herbsjs / herbs2gql

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

Error using a entity as a field of another entity #43

Closed Vx-Nico closed 2 years ago

Vx-Nico commented 2 years ago

Describe the bug When I use a entity as a field of another entity, for some reason it threw an Unknow type error.

To Reproduce Create an entity Import this entity into another entity Use this imported entity as a field

example:

const { field, entity } = require('@herbsjs/herbs')
const B = require('../entities')

const A = entity("A", {
    B: field(B)
})

module.exports = A

Update the entities index

example:

module.exports = {
    A: require('./A'),
    B: require('./B')
}

Check the log when you run the application

Expected behavior Graphql should create type and input without error

Screenshots imagem erro

jhomarolo commented 2 years ago

@Vx-Nico your image is crashed.

Also could you please send the error here? Its not clear the error message

Vx-Nico commented 2 years ago

I updated the screenshot, see if is clearer now

anahelenasilva commented 2 years ago

I had the same issue as @Vx-Nico when doing the same thing

italojs commented 2 years ago

do you have a solution to propose for this problem? if not, could you provide a sample/full/simple script for us reproduce the error and try to solve the problem?

dalssoft commented 2 years ago

Checking the current tests it seems there is no implementation/support for entity fields with types of entities and entities arrays. The only place that I could find support is here:

https://github.com/herbsjs/herbs2gql/blob/master/test/usecase2query.test.js#L180 https://github.com/herbsjs/herbs2gql/blob/master/test/usecase2subscription.test.js#L267

However it should not be difficult to implement. PRs are welcome.

jhomarolo commented 2 years ago

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

The release is available on:

Your semantic-release bot :package::rocket: