Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scalar fields in relationships #5111

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
import type { InputTypeComposer, ListComposer, NonNullComposer, ObjectTypeComposer } from "graphql-compose";
import { Memoize } from "typescript-memoize";
import type { Attribute } from "../../../schema-model/attribute/Attribute";
import { AttributeAdapter } from "../../../schema-model/attribute/model-adapters/AttributeAdapter";
import { ConcreteEntity } from "../../../schema-model/entity/ConcreteEntity";
import type { Relationship } from "../../../schema-model/relationship/Relationship";
import { attributeAdapterToComposeFields } from "../../../schema/to-compose";
import type { NestedEntityTypeNames } from "../../graphQLTypeNames/NestedEntityTypeNames";
import type { SchemaBuilder } from "../SchemaBuilder";
import type { FieldDefinition, SchemaBuilder } from "../SchemaBuilder";
import { EntityTypes } from "./EntityTypes";
import type { StaticTypes } from "./StaticTypes";

Expand Down Expand Up @@ -71,9 +73,11 @@ export class NestedEntitySchemaTypes extends EntityTypes<NestedEntityTypeNames>
protected getConnectionArgs(): { sort?: ListComposer<NonNullComposer<InputTypeComposer>> | undefined } {
return {};
}
private getRelationshipFields(): Record<string, string> {
return Object.fromEntries(
[...this.relationship.attributes.values()].map((attribute) => [attribute.name, attribute.type.name])
private getRelationshipFields(): Record<string, FieldDefinition> {
const entityAttributes = [...this.relationship.attributes.values()].map(
(attribute) => new AttributeAdapter(attribute)
);

return attributeAdapterToComposeFields(entityAttributes, new Map()) as Record<string, any>;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ describe("@alias directive", () => {
},
});
});
// this test fail, I believe is because the numeric resolver was not added on the relationship properties
test.skip("Query node and relationship with alias", async () => {

test("Query node and relationship with alias", async () => {
const query = /* GraphQL */ `
query {
${Movie.plural} {
Expand Down