From 517a5c771b584b2d00689e6a3cf8b0f09222697c Mon Sep 17 00:00:00 2001 From: David de Boer Date: Thu, 23 Nov 2023 16:43:27 +0100 Subject: [PATCH] feat: Add term definition (#1167) * Start by copying the value of scopeNote. * Document in the GraphQL API that the value of scopeNote may change later. --- jest.config.js | 6 +++--- packages/network-of-terms-graphql/src/resolvers.ts | 1 + packages/network-of-terms-graphql/src/schema.ts | 2 ++ packages/network-of-terms-graphql/test/server.test.ts | 4 ++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/jest.config.js b/jest.config.js index 231854f83..35bd3ca4c 100644 --- a/jest.config.js +++ b/jest.config.js @@ -11,9 +11,9 @@ export default { ], coverageThreshold: { global: { - lines: 90.94, - statements: 90.94, - branches: 95.86, + lines: 90.95, + statements: 90.95, + branches: 95.87, functions: 91.52, }, }, diff --git a/packages/network-of-terms-graphql/src/resolvers.ts b/packages/network-of-terms-graphql/src/resolvers.ts index 7d4702091..ba7bcceac 100644 --- a/packages/network-of-terms-graphql/src/resolvers.ts +++ b/packages/network-of-terms-graphql/src/resolvers.ts @@ -116,6 +116,7 @@ function term(term: Term) { hiddenLabel: term.hiddenLabels.map( (hiddenLabel: RDF.Term) => hiddenLabel.value ), + description: term.scopeNotes.map((scopeNote: RDF.Term) => scopeNote.value), scopeNote: term.scopeNotes.map((scopeNote: RDF.Term) => scopeNote.value), seeAlso: term.seeAlso.map((seeAlso: RDF.NamedNode) => seeAlso.value), broader: term.broaderTerms.map(related => ({ diff --git a/packages/network-of-terms-graphql/src/schema.ts b/packages/network-of-terms-graphql/src/schema.ts index eb54d6551..c5a449c8e 100644 --- a/packages/network-of-terms-graphql/src/schema.ts +++ b/packages/network-of-terms-graphql/src/schema.ts @@ -44,6 +44,8 @@ export const schema = ` prefLabel: [String]! altLabel: [String]! hiddenLabel: [String]! + description: [String]! + "For the full description of the term, use \`description\` instead of scopeNote. The contents of \`scopeNote\` may change later." scopeNote: [String]! seeAlso: [String]! broader: [RelatedTerm] diff --git a/packages/network-of-terms-graphql/test/server.test.ts b/packages/network-of-terms-graphql/test/server.test.ts index f0c102891..f89071f5f 100644 --- a/packages/network-of-terms-graphql/test/server.test.ts +++ b/packages/network-of-terms-graphql/test/server.test.ts @@ -102,6 +102,9 @@ describe('Server', () => { term.uri === 'https://example.com/resources/artwork' ); expect(artwork.seeAlso).toEqual(['https://example.com/html/artwork']); + expect(artwork.description).toEqual([ + 'One of the most famous Dutch paintings', + ]); const prefLabels = body.data.terms[0].result.terms.map( ({prefLabel}: {prefLabel: string[]}) => prefLabel[0] ?? '' @@ -229,6 +232,7 @@ function termsQuery(sources: string[], query = 'nachtwacht') { prefLabel altLabel hiddenLabel + description scopeNote seeAlso broader {