Skip to content

Commit

Permalink
Merge pull request #134 from smartive/break/extend-query
Browse files Browse the repository at this point in the history
break: Extend query builders
  • Loading branch information
nickredmark authored Feb 5, 2024
2 parents a50b998 + d06750c commit bc6e8f7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/client/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ ${model.displayField ? `display: ${model.displayField}` : ''}
export const getEntityListQuery = (
model: EntityModel,
role: string,
visibleRelationsByRole: VisibleRelationsByRole,
typesWithSubRelations: string[],
additionalFields = '',
root?: {
model: EntityModel;
Expand All @@ -167,6 +169,13 @@ export const getEntityListQuery = (
${displayField(model)}
${model.fields.filter(and(isSimpleField, isQueriableBy(role))).map(({ name }) => name)}
${additionalFields}
${queryRelations(
model.models,
model.relations.filter(isVisibleRelation(visibleRelationsByRole, model.name, role)),
role,
typesWithSubRelations
)}
${additionalFields}
}
${root ? '}' : ''}
}`;
Expand All @@ -182,7 +191,8 @@ export const getEntityQuery = (
model: EntityModel,
role: string,
visibleRelationsByRole: VisibleRelationsByRole,
typesWithSubRelations: string[]
typesWithSubRelations: string[],
additionalFields = ''
) => `query Get${model.name}Entity ($id: ID!) {
data: ${typeToField(model.name)}(where: { id: $id }) {
${displayField(model)}
Expand All @@ -203,6 +213,7 @@ export const getEntityQuery = (
role,
typesWithSubRelations
)}
${additionalFields}
}
}`;

Expand Down

0 comments on commit bc6e8f7

Please sign in to comment.