Skip to content

Commit dc8ba61

Browse files
committed
Fix GraphQL field names: Remove aliases for paintingLabel and locationLabel
The GraphQL schema doesn't support field aliases like 'title: paintingLabel'. Changed to query fields directly as 'paintingLabel' and 'locationLabel' and updated all component references accordingly. - Updated GraphQL queries in Index.vue and Painting.vue - Updated component references from .title to .paintingLabel - Updated component references from .location to .locationLabel - Updated test mocks to use correct field names Fixes GitHub Action build error: Error: Cannot query field 'paintingLabel' on type 'Painting'.
1 parent 31a6508 commit dc8ba61

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@
4040
"@babel/core": "^7.25.0",
4141
"@babel/eslint-parser": "^7.25.0",
4242
"@babel/preset-env": "^7.25.0",
43-
"@vue/test-utils": "^1.3.0",
44-
"@vue/vue2-jest": "^29.0.0",
45-
"babel-jest": "^29.7.0",
4643
"eslint": "^9.39.1",
4744
"eslint-config-prettier": "^10.1.8",
4845
"eslint-loader": "^4.0.2",
@@ -51,13 +48,16 @@
5148
"eslint-plugin-vue": "^10.6.2",
5249
"gh-pages": "^6.3.0",
5350
"globals": "^15.11.0",
54-
"jest": "^29.7.0",
55-
"jest-environment-jsdom": "^29.7.0",
5651
"lodash": "^4.17.21",
5752
"prettier": "^3.7.4",
5853
"sass": "^1.77.0",
5954
"sass-loader": "^10.5.2",
60-
"vue-eslint-parser": "^10.0.0"
55+
"vue-eslint-parser": "^10.0.0",
56+
"@vue/test-utils": "^1.3.0",
57+
"@vue/vue2-jest": "^29.0.0",
58+
"jest": "^29.7.0",
59+
"jest-environment-jsdom": "^29.7.0",
60+
"babel-jest": "^29.7.0"
6161
},
6262
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
6363
}

src/components/CardLayout.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
v-if="painting.cover_image"
66
:src="painting.cover_image"
77
:alt="
8-
painting.title
9-
? `${painting.title} - Cover image`
8+
painting.paintingLabel
9+
? `${painting.paintingLabel} - Cover image`
1010
: 'Artwork cover image'
1111
"
1212
loading="lazy"
1313
/>
1414
</div>
1515
<div class="card-layout__content">
16-
<h2 class="card-layout__title">{{ painting.title }}</h2>
16+
<h2 class="card-layout__title">{{ painting.paintingLabel }}</h2>
1717
<div>Year: {{ painting.year }}</div>
18-
<div>Collection: {{ painting.location }}</div>
18+
<div>Collection: {{ painting.locationLabel }}</div>
1919
<div>Material: {{ painting.materials }}</div>
2020
<TagCloud class="card-layout__tags" :event="addTag()" :tags="getTags()" />
2121
<ActionBar class="card-layout__actions" :painting="painting" />

src/components/__tests__/ActionBar.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Vue.prototype.$eventBus = new Vue();
1010
describe("ActionBar", () => {
1111
const mockPainting = {
1212
path: "/Q12345",
13-
title: "Test Painting",
13+
paintingLabel: "Test Painting",
1414
image: "https://example.com/image.jpg",
1515
cover_image: "https://example.com/cover.jpg"
1616
};

src/components/__tests__/CardLayout.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ localVue.component("g-link", {
2424
describe("CardLayout", () => {
2525
const mockPainting = {
2626
id: "1",
27-
title: "Test Painting",
27+
paintingLabel: "Test Painting",
2828
year: "1503",
29-
location: "Louvre",
29+
locationLabel: "Louvre",
3030
materials: "Oil on canvas",
3131
tags: ["1503", "Louvre", "portrait"],
3232
path: "/test-painting",

src/pages/Index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ query {
5050
node {
5151
id
5252
path
53-
title: paintingLabel
53+
paintingLabel
5454
image
5555
cover_image: image (width: 770, height: 380, blur: 10)
5656
year: date (format: "YYYY")
57-
location: locationLabel
57+
locationLabel
5858
materials
5959
depicts
6060
}
@@ -165,7 +165,7 @@ export default {
165165
if (this.$page.paintings && this.$page.paintings.edges) {
166166
this.$page.paintings.edges.forEach(edge => {
167167
// basic tags
168-
edge.node.tags = [edge.node.year, edge.node.location];
168+
edge.node.tags = [edge.node.year, edge.node.locationLabel];
169169
// concat with available depicts (with null safety)
170170
if (edge.node.depicts) {
171171
edge.node.tags = edge.node.tags.concat(edge.node.depicts.split(","));

src/templates/Painting.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@
1010
</div>
1111
<div v-else>
1212
<h1 class="painting__header">
13-
{{ $page.painting.title || "Untitled" }}
13+
{{ $page.painting.paintingLabel || "Untitled" }}
1414
</h1>
1515
<div class="painting__content">
1616
<g-image
1717
v-if="$page.painting.image"
1818
:src="$page.painting.image"
1919
:alt="
20-
$page.painting.title
21-
? `${$page.painting.title} by Leonardo da Vinci`
20+
$page.painting.paintingLabel
21+
? `${$page.painting.paintingLabel} by Leonardo da Vinci`
2222
: 'Painting by Leonardo da Vinci'
2323
"
2424
loading="lazy"
2525
/>
2626
<div v-if="$page.painting.year">Year: {{ $page.painting.year }}</div>
27-
<div v-if="$page.painting.location">
28-
Collection: {{ $page.painting.location }}
27+
<div v-if="$page.painting.locationLabel">
28+
Collection: {{ $page.painting.locationLabel }}
2929
</div>
3030
<div v-if="$page.painting.materials">
3131
Material: {{ $page.painting.materials }}
@@ -45,8 +45,8 @@ export default {
4545
};
4646
}
4747
48-
const title = this.$page.painting.title || "Untitled Painting";
49-
const description = `${title} by Leonardo da Vinci. ${this.$page.painting.year ? `Created in ${this.$page.painting.year}.` : ""} ${this.$page.painting.location ? `Collection: ${this.$page.painting.location}.` : ""}`;
48+
const title = this.$page.painting.paintingLabel || "Untitled Painting";
49+
const description = `${title} by Leonardo da Vinci. ${this.$page.painting.year ? `Created in ${this.$page.painting.year}.` : ""} ${this.$page.painting.locationLabel ? `Collection: ${this.$page.painting.locationLabel}.` : ""}`;
5050
const image = this.$page.painting.image || "";
5151
const siteUrl =
5252
process.env.GRIDSOME_SITE_URL || "https://hunsalz.github.io";
@@ -110,10 +110,10 @@ query painting ($id: ID!) {
110110
painting: painting (id: $id) {
111111
id
112112
path
113-
title: paintingLabel
113+
paintingLabel
114114
image
115115
year: date (format: "YYYY")
116-
location: locationLabel
116+
locationLabel
117117
materials
118118
depicts
119119
}

0 commit comments

Comments
 (0)