katharsis-project / katharsis-framework

Katharsis adds powerful layer for RESTful endpoints providing implementenation of JSON:API standard
http://katharsis.io
Apache License 2.0
135 stars 65 forks source link

When fetching relations, there's no meta data attached. #425

Open jianglibo opened 7 years ago

jianglibo commented 7 years ago

Katharsis doesn't return meta info when fetching relations. I'm not sure whether it follows the jsonapi spec. for example:

/articles/1/comments

If there were thousands of comments for that article, should I return them all? or be paged? I just count this problem today.

jianglibo commented 7 years ago

look into the code, this is where links and meta be discarded:

    @Override
    public ResourceList<D> findManyTargets(I sourceId, String fieldName, QuerySpec querySpec) {
        MultivaluedMap<I, D> map = findTargets(Arrays.asList(sourceId), fieldName, querySpec);
        if (map.isEmpty()) {
            return new DefaultResourceList<>();
        }
        return (ResourceList<D>) map.getList(sourceId);
    }

This method always call "findTargets" with one unique sourceId, why does it need filter out mata information from it? /sections/1/articles, this kind of relationship is very common. without the mata information, it need to construct the url manually. like /articles?filter[section]=1