Merge pull request #778 from directus/graphql

Fix relational fetching in graphql endpoint
This commit is contained in:
Rijk van Zanten
2020-10-26 11:51:50 +01:00
committed by GitHub
2 changed files with 5 additions and 4 deletions

View File

@@ -18,7 +18,6 @@ import {
GraphQLInputObjectType,
ObjectFieldNode,
GraphQLID,
ValueNode,
FieldNode,
GraphQLFieldConfigMap,
GraphQLInt,
@@ -26,11 +25,9 @@ import {
StringValueNode,
BooleanValueNode,
ArgumentNode,
GraphQLScalarType,
GraphQLBoolean,
ObjectValueNode,
GraphQLUnionType,
GraphQLUnionTypeConfig,
} from 'graphql';
import { getGraphQLType } from '../utils/get-graphql-type';
import { RelationsService } from './relations';
@@ -65,7 +62,7 @@ export class GraphQLService {
this.knex = options?.knex || database;
this.fieldsService = new FieldsService(options);
this.collectionsService = new CollectionsService(options);
this.relationsService = new RelationsService({ knex: this.knex });
this.relationsService = new RelationsService(options);
}
args = {
@@ -138,6 +135,7 @@ export class GraphQLService {
const relatedIsSystem = relationForField.one_collection!.startsWith(
'directus_'
);
const relatedType = relatedIsSystem
? schema[relationForField.one_collection!.substring(9)].type
: schema.items[relationForField.one_collection!].type;

View File

@@ -25,7 +25,9 @@ export class RelationsService extends ItemsService {
| ParsedRelation
| ParsedRelation[]
| null;
const filteredResults = await this.filterForbidden(results);
return filteredResults;
}
@@ -58,6 +60,7 @@ export class RelationsService extends ItemsService {
this.accountability?.role || null,
'read'
);
const allowedFields = await this.permissionsService.getAllowedFields(
this.accountability?.role || null,
'read'