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

[Bug]: Error with @adminjs/relations: "No property of the name: 'relations'" for Event Resource #1731

Open
melyamri opened this issue Jan 3, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@melyamri
Copy link

melyamri commented Jan 3, 2025

Contact Details

No response

What happened?

AdminJS is not showing relations for a resource Event when using @adminjs/relations. All other resources in the database work as expected and show their relations. The issue only occurs with the Event resource.

The @adminjs/relations package throws the error:

[AdminJS]: There is no property of the name: "relations". Check out the "showProperties" in the resource: "events".
The Event resource is configured like this:

export const createEventResource = () => ({
  resource: new LucidResource(Event, 'postgres'),
  options: {
    navigation: { name: null, icon: 'Calendar' },
    listProperties: ['id', 'name', 'description', 'startDate', 'endDate', 'createdAt', 'updatedAt'],
    filterProperties: ['name', 'description'],
    editProperties: ['name', 'description', 'startDate', 'endDate'],
    showProperties: ['id', 'name', 'description', 'startDate', 'endDate', 'createdAt', 'updatedAt', 'relations'],
    properties: {
      name: { isTitle: true },
      description: { type: 'richtext' },
      startDate: { type: 'datetime' },
      endDate: { type: 'datetime' },
      sort: { sortBy: 'updatedAt', direction: 'desc' },
    },
    features: [
      targetRelationSettingsFeature(),
      owningRelationSettingsFeature({
        componentLoader,
        licenseKey: process.env.ADMINJS_RELATIONS_LICENSE_KEY!,
        relations: {
          places: {
            type: RelationType.ManyToMany,
            junction: { joinKey: 'eventId', inverseJoinKey: 'placeId', throughResourceId: 'place_events' },
            target: { resourceId: 'places' },
          },
        },
      }),
    ],
  },
});

Additional context

I'm using AdminJS with AdonisJS and Lucid ORM.

Any insights on whether the name "Event" or another configuration issue might be causing the conflict would be greatly appreciated.

Bug prevalence

Always

AdminJS dependencies version

{
"@adminjs/adonis": "^1.1.0",
"@adminjs/passwords": "^4.0.0",
"@adminjs/relations": "^1.1.2",
"adminjs": "^7.8.7",
}

What browsers do you see the problem on?

Chrome, Microsoft Edge

Relevant log output

[AdminJS]: There is no property of the name: "relations". Check out the "showProperties" in the resource: "events".

Relevant code that's giving you issues

export const createEventResource = () => ({
  resource: new LucidResource(Event, 'postgres'),
  options: {
    navigation: { name: null, icon: 'Calendar' },
    listProperties: ['id', 'name', 'description', 'startDate', 'endDate', 'createdAt', 'updatedAt'],
    filterProperties: ['name', 'description'],
    editProperties: ['name', 'description', 'startDate', 'endDate'],
    showProperties: ['id', 'name', 'description', 'startDate', 'endDate', 'createdAt', 'updatedAt', 'relations'],
    properties: {
      name: { isTitle: true },
      description: { type: 'richtext' },
      startDate: { type: 'datetime' },
      endDate: { type: 'datetime' },
      sort: { sortBy: 'updatedAt', direction: 'desc' },
    },
    features: [
      targetRelationSettingsFeature(),
      owningRelationSettingsFeature({
        componentLoader,
        licenseKey: process.env.ADMINJS_RELATIONS_LICENSE_KEY!,
        relations: {
          places: {
            type: RelationType.ManyToMany,
            junction: { joinKey: 'eventId', inverseJoinKey: 'placeId', throughResourceId: 'place_events' },
            target: { resourceId: 'places' },
          },
        },
      }),
    ],
  },
});
@melyamri melyamri added the bug Something isn't working label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant