Skip to content

Commit

Permalink
Merge pull request #5111 from neo4j/fix-scalar-fields
Browse files Browse the repository at this point in the history
Fix scalar fields in relationships
  • Loading branch information
angrykoala committed May 13, 2024
2 parents 92c747d + ad7f10e commit 299b7b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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

0 comments on commit 299b7b5

Please sign in to comment.