Closed unlight closed 3 years ago
Can you give me your frontend requested fields, please?
query articles {
articles: articles(where: {}, orderBy: { id: desc }) {
...articleFields
}
articlesCount: countArticles(where: {})
}
fragment articleFields on Article {
slug
title
description
body
tags {
name
}
createdAt
updatedAt
favorited
favoritesCount
author {
...userFields
following
}
}
fragment userFields on User {
username: name
email
bio
image
}
Can you upgrade to the last version 2.8.4
and check again?
Checked with 2.8.4
still same error.
I just realized that bug is probably wrongly. Part of schema:
model User {
// ...
userId String @id
following User[] @relation("UserFollows", references: [userId])
}
following
is array of users
I do not need this behavior (expose this field to graphql schema), and override this by NestJS decorator ResolveField
@ResolveField(() => Boolean)
async following(
@Parent() user: User,
@CurrentUser() currentUser?: PassportUserFields,
): Promise<boolean> {
// implementation
}
Then I found piece of code
var client = require('@prisma/client');
require('@prisma/client/runtime');
//...
_proto.model = function model(name) {
var _this$dataModel;
return (_this$dataModel = this.dataModel) === null || _this$dataModel === void 0 ? void 0 : _this$dataModel.models.find(function (item) {
return item.name === name || PrismaSelect.getModelMap(item.documentation, name);
});
};
Looks like select some how depend on generated dmmf of prisma client.
Which is looks weird for me.
You can't do it like this.
My plugin converts GraphQL fields to be Prisma Select objects.
So now my plugin will deal with the following
field as a User object.
Please, you can use another name for your field, not in. Your model.
I do not understand why it is necessary. Can you explain why plugin relies on dmmf? This is the old implementation https://github.com/frandiox/graphql-info-transformer/blob/master/index.js of similar behavior (only graphql info ast is used).
Because if you added in your graphql type any fields, not in your prisma model and I added them to select object, this will break your prisma query I must filter your fields coming from Info and just give you what you can send to a Prisma select object
Evaluates to
Info object