Is there a suggested approach to generate a relationship link?

Q: Is there a suggested approach to generate a relationship link?

I have an article with a hasMany relationship to comments, but the article response does not contain a relationship link, so I must add a relationship link to the comments via links property - as suggested by https://davidtang.io/2016/02/21/handling-nested-resources-in-ember-data.html and Customizing Relationship Links with JSON API - Ember Igniter articles.

While adding the link in the serializer works, the examples I’ve seen have the URLs for the link hardcoded in the serializer. Having the URLs hardcoded in the serializer seems like it could be confusing and cause possible maintenance issues since the adapter is where the URLs for models is usually created.

Is there an Ember Data recommended approach to generate links for relationships when the payload does not contain the links?

For context, below are the responses of the APIs I am working with.

Article Response - (/articles/:slug)

{
    "article":{
        "title":"Pudding!",
        "slug":"pudingi-7sz17d",
        "body":"Hi Hello How are you!",
        "createdAt":"2019-08-22T08:45:15.787Z",
        "updatedAt":"2019-08-22T08:45:15.787Z",
        "tagList":[],
        "description":"Myself",
        "author":{
            "username":"Srinivasa",
            "bio":null,
            "image":"https://static.productionready.io/images/smiley-cyrus.jpg",
            "following":false
        },
        "favorited":false,
        "favoritesCount":2
    }
}

Comments Response - (/articles/:slug/comments)

{
    "comments":[
        {
            "id":44616,
            "createdAt":"2019-08-22T09:31:56.531Z",
            "updatedAt":"2019-08-22T09:31:56.531Z",
            "body":"Doing well. How are you?",
            "author":{
                "username":"gc-conduit",
                "bio":null,
                "image":"https://static.productionready.io/images/smiley-cyrus.jpg",
                "following":false
            }
        }
    ]
}

Everything I’ve ever seen had it in the serializer, and I think that makes sense. In a way you’re saying “here’s a record from the backend, it doesn’t look exactly how i’d like it to, so I’m supplementing and/or transforming it”. That is the job of the serializer. You’re right that the adapter usually creates request URLs but those are generally derived from business logic whereas these relationship links are actually part of the data itself (which is more the concern of the serializer layer).

So you’re saying that what you’ve seen is that links have been in the serializer because it’s the serializers responsibility to shape the data to be consumed by the application?

If so I agree with you there. I just want to prevent hardcoding the path. I wonder if I can use a combination of the adapter methods in the serializer to generate the path…