Skip to content

Relationship keys are not getting converted to camelCase #106

Description

@nataliepatton13

When defining a model, it appears that only attributes are getting converted to camelCase but relationship keys have to be defined in snake case or else I get the error Unknown type "appointment_requests"

I have an Appointment model that is currently setup like this:

const Appointment = ApplicationRecord.extend({
  static: {
    jsonapiType: "appointments",
  },
  attrs: {
    appointmentRequests: hasMany(),
  },
});

It has a has many relationship to the AppointmentRequests model that looks like this:

const AppointmentRequests = ApplicationRecord.extend({
  static: {
    jsonapiType: "appointmentRequests",
  },
  attrs: {
    appointment: belongsTo(),
    startTime: attr(),
  },
});

However, I currently have to change appointmentRequests to appointment_requests in both models in order to be able to access the related appointment requests from an appointment record. It seems like I should be able to define the relationships in camelCase since other attributes get converted from snake_case to camelCase correctly. Has anyone else seen or run into this issue before?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions