Skip to content

Commit

Permalink
feat: add GraphQL queries and fragments for material and work + updat…
Browse files Browse the repository at this point in the history
…e TypeScript configuration
  • Loading branch information
ThomasGross committed Nov 19, 2024
1 parent cb1cec1 commit 5385cb3
Show file tree
Hide file tree
Showing 7 changed files with 566 additions and 6 deletions.
8 changes: 5 additions & 3 deletions app/work/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from "react"

function Page({ searchParams, queryParams }) {
function Page({ params: { id } }: { params: { id: string } }) {



return (
<div>
<pre>{JSON.stringify(queryParams, null, 2)}</pre>
<pre>{JSON.stringify(searchParams, null, 2)}</pre>
<pre>{JSON.stringify(id, null, 2)}</pre>
Page
</div>
)
Expand Down
152 changes: 152 additions & 0 deletions lib/graphql/fragments/manifestation.fbi.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,155 @@ fragment ManifestationIdentifiers on Manifestation {
value
}
}

fragment Manifestations on Manifestations {
all {
...ManifestationsFields
}
latest {
...ManifestationsFields
}
bestRepresentation {
...ManifestationsFields
}
}

fragment ManifestationsAccess on Manifestations {
all {
pid
identifiers {
type
value
}
access {
__typename
... on AccessUrl {
origin
url
loginRequired
}
... on InfomediaService {
id
}
... on InterLibraryLoan {
loanIsPossible
}
... on Ereol {
origin
url
canAlwaysBeLoaned
}
... on DigitalArticleService {
issn
}
}
}
}

fragment ManifestationsFields on Manifestation {
pid
genreAndForm
source
# ...WithLanguages
titles {
main
original
}
fictionNonfiction {
display
code
}
materialTypes {
materialTypeSpecific {
display
}
}
creators {
display
nameSort
__typename
}
publisher
identifiers {
value
}
contributors {
display
roles {
function {
singular
}
}
}
edition {
summary
publicationYear {
display
}
}
dateFirstEdition {
display
year
}
audience {
generalAudience
ages {
display
}
}
notes {
display
}
languages {
notes
}
physicalDescription {
summaryFull
numberOfPages
# playingTime
}
hostPublication {
summary
}
manifestationParts {
parts {
title
}
}
accessTypes {
code
}
access {
__typename
... on AccessUrl {
origin
url
loginRequired
}
... on InfomediaService {
id
}
... on InterLibraryLoan {
loanIsPossible
}
... on Ereol {
origin
url
canAlwaysBeLoaned
}
... on DigitalArticleService {
issn
}
}
shelfmark {
postfix
shelfmark
}
workYear {
year
}
catalogueCodes {
nationalBibliography
otherCatalogues
}
}
87 changes: 87 additions & 0 deletions lib/graphql/fragments/work.fbi.graphql
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
fragment SeriesSimple on Series {
title
isPopular
members {
numberInSeries
work {
workId
titles {
main
}
}
}
readThisFirst
readThisWhenever
}

fragment WorkAccess on Work {
workId
manifestations {
...ManifestationsAccess
}
}

fragment WorkTeaser on Work {
workId
titles {
Expand Down Expand Up @@ -26,3 +49,67 @@ fragment WorkTeaser on Work {
}
}
}

fragment Work on Work {
workId
titles {
full
original
}
abstract
creators {
display
__typename
}
series {
...SeriesSimple
}
workYear {
year
}
genreAndForm
manifestations {
...Manifestations
}
materialTypes {
materialTypeSpecific {
display
}
}
creators {
nameSort
}
mainLanguages {
display
isoCode
}
subjects {
all {
display
}
dbcVerified {
display
}
}
fictionNonfiction {
display
code
}
dk5MainEntry {
display
}
relations {
hasReview {
pid
}
hasAdaptation {
ownerWork {
workId
workTypes
titles {
main
}
}
}
}
}
314 changes: 314 additions & 0 deletions lib/graphql/generated/fbi/graphql.tsx

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions lib/graphql/queries/material.fbi.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query getMaterial($wid: String!) {
work(id: $wid) {
...Work
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"format:check": "prettier --check .",
"format:write": "prettier --write .",
"test:unit": "vitest",
"codegen:graphql": "graphql-codegen --config codegen.ts",
"codegen:graphql": "graphql-codegen --require tsconfig-paths/register --config codegen.ts",
"codegen:all-rest-services": "orval",
"codegen:covers": "rm -rf src/lib/rest/cover-service-api/generated/model/*.* && orval --project coverService",
"codegen:publizon": "rm -rf lib/rest/publizon-api/generated/model/*.* && orval --project publizonAdapter",
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"schema": "graphql/generated/dpl-cms/graphql.schema.json"
}
],
"baseUrl": ".",
"paths": {
"@/*": ["./*"]
}
Expand All @@ -32,7 +33,6 @@
"node_modules",
"lib/rest/cover-service-api/model",
"lib/rest/cover-service-api/cover-service.ts",
"lib/graphql/generated/fbi/*.tsx",
"__tests__"
"lib/graphql/generated/fbi/*.tsx"
]
}

0 comments on commit 5385cb3

Please sign in to comment.