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

Pivot fields missing for uni-directional relation #101

Open
erikgaal opened this issue Mar 1, 2019 · 0 comments
Open

Pivot fields missing for uni-directional relation #101

erikgaal opened this issue Mar 1, 2019 · 0 comments
Labels

Comments

@erikgaal
Copy link
Contributor

erikgaal commented Mar 1, 2019

Describe the bug
When a relation is only specified in one direction on the ModelSchema, then the pivot fields are on the wrong side of the relation. For example, when there is a relationship users belongs to many roles, there is a rolesPivot on the User type. While there should only be a usersPivot on the Roles type, because there is no way to retrieve the users from the roles.

To Reproduce

// UserSchema.php
public function relations(): array
{
    return [
        'roles' => Field::collection(RoleSchema::class),
    ];
}

// RoleSchema.php
public function relations(): array
{
    return [];
}

// UserRole.php
public function fields(): array
{
    return [
        'comment' => Field::string(),
    ];
}
{
  user(id: 1) {
    roles {
      userPivot { comment }
    }
  }
}

# "{"errors":[{"message":"Cannot query field \"userPivot\" on type \"Role\".","category":"graphql","locations":[{"line":3,"column":17}]}]}"
  • Laravel Version: v5.7.27
  • Bakery Version v3.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant