Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: relation type "HasManyRelation" is not supported #78

Open
ryanvanderpol opened this issue Apr 10, 2019 · 0 comments
Open

Error: relation type "HasManyRelation" is not supported #78

ryanvanderpol opened this issue Apr 10, 2019 · 0 comments

Comments

@ryanvanderpol
Copy link

I have two models (Order and OrderItems) where Order has relationMappings defined as follows:

    static get relationMappings(){

        const OrderItem = require('./OrderItem');

        return {
            items: {
                relation: Model.HasManyRelation,
                modelClass: OrderItem,
                join: {
                    from: 'orders.id',
                    to: 'order_items.order_id'
                }
            }
        }
    }

When I use the GraphQL Builder, as follows:

const schema = builder()
  .model(Order, { fieldName: 'order', listFieldName: 'orders' })
  .model(OrderItem)
  .build();

I get the following error:

Error: relation type "HasManyRelation" is not supported
    at SchemaBuilder._relationField (/.../node_modules/objection-graphql/lib/SchemaBuilder.js:243:11)

Looking at the code in the _relationField method it seems that HasManyRelation should be supported.

Not 100% sure why this is happening, but it might be related to the fact that I have all my models defined in a separate NPM package so the instanceof objection.HasManyRelation check isn't referring to the same instance of objection that the models were built with?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant