Skip to content

Commit

Permalink
feat v2.1: updated some kind of query schema
Browse files Browse the repository at this point in the history
  • Loading branch information
hUwUtao committed Nov 28, 2024
1 parent 4b89372 commit d67628e
Show file tree
Hide file tree
Showing 15 changed files with 281 additions and 205 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
src/graphql/**
2 changes: 1 addition & 1 deletion biome.jsonc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.1/schema.json",
"files": {
"include": ["src/**/*"]
"include": ["src/**/*", "!src/graphql/**/*"]
},
"organizeImports": {
"enabled": false
Expand Down
2 changes: 0 additions & 2 deletions blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@
# from wagtail_wordpress_import.models import WPImportedPageMixin

from grapple.models import (
GraphQLRichText,
GraphQLString,
GraphQLStreamfield,
GraphQLImage,
GraphQLForeignKey,
)


Expand Down
8 changes: 7 additions & 1 deletion codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ const config: CodegenConfig = {
generates: {
'./src/graphql/': {
preset: 'client',
presetConfig: {
persistedDocuments: true,
fragmentMasking: false,
},
config: {
documentMode: 'string'
documentMode: 'string',
dedupeFragments: true,
constEnums: true
}
},
'./src/graphql/schema.graphql': {
Expand Down
16 changes: 16 additions & 0 deletions gallery/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@

# keep the definition of BlogIndexPage model, and add the BlogPage model:

from grapple.models import (
GraphQLRichText,
GraphQLString,
GraphQLStreamfield,
GraphQLImage,
GraphQLForeignKey,
GraphQLInt,
)


class Picture(HeadlessMixin, Page, TFRenditionGroup):
image = models.ForeignKey(
TFImage,
Expand Down Expand Up @@ -57,3 +67,9 @@ def image_set(self):
# 'authors'
# ), # This will nest the relevant BlogPageAuthor objects in the API response
]

graphql_fields = [
GraphQLString('cap'),
GraphQLImage('image'),
GraphQLString('image_date'),
]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@team-fuho/wt",
"version": "2.0.1",
"version": "2.1.0",
"description": "powered by `wagtail`. awesome!",
"type": "module",
"main": "dist/index.js",
Expand Down
122 changes: 75 additions & 47 deletions src/client.gql
Original file line number Diff line number Diff line change
@@ -1,62 +1,90 @@
fragment BlogPageView on BlogPage {
fragment BlogPageOuterView on BlogPage {
id
slug
title
seoTitle
thumb {
id
slug
title
seoTitle
thumb {
id
rendition(width: 1920, height: 1080, format: "webp") {
id
url
}
rendition(width: 1920, height: 1080, format: "webp") {
id
url
}
}
}

fragment BlogPageViewInner on BlogPage {
body {
... on StreamFieldInterface {
blockType
}
... on RichTextBlock {
value
}
... on ImageBlock {
caption
link
alignment
image {
url
width
height
}
}
... on QuoteBlock {
quote
attribution
}
... on HeadingBlock {
text
importance
}
fragment BlogPageInnerView on BlogPage {
body {
... on StreamFieldInterface {
blockType
}
... on RichTextBlock {
value
}
... on ImageBlock {
caption
link
alignment
image {
url
width
height
}
}
... on QuoteBlock {
quote
attribution
}
... on HeadingBlock {
text
importance
}
}
}

fragment GalleryOuterView on Picture {
id
cap
image {
id
url
}
imageDate
}

query GalleryListView {
pages(contentType: "gallery.Picture") {
...GalleryOuterView
}
}

query GalleryPaginatedListView($offset: PositiveInt, $limit: PositiveInt) {
pages(contentType: "gallery.Picture", offset: $offset, limit: $limit) {
...GalleryOuterView
}
}

query BlogListView {
pages(contentType: "blog.BlogPage") {
...BlogPageView
}
pages(contentType: "blog.BlogPage") {
...BlogPageOuterView
}
}

query BlogPaginatedListView($offset: PositiveInt, $limit: PositiveInt) {
pages(contentType: "blog.BlogPage", offset: $offset, limit: $limit) {
...BlogPageOuterView
}
}

query BlogPreviewView($token: String) {
page(id: 0, token: $token) {
...BlogPageView
...BlogPageViewInner
}
page(id: 0, token: $token) {
...BlogPageOuterView
...BlogPageInnerView
}
}

query BlogLiveView($slug: String) {
page(slug: $slug) {
...BlogPageView
...BlogPageViewInner
}
page(slug: $slug) {
...BlogPageOuterView
...BlogPageInnerView
}
}
83 changes: 0 additions & 83 deletions src/graphql/fragment-masking.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/graphql/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import * as types from './graphql';
* Learn more about it here: https://the-guild.dev/graphql/codegen/plugins/presets/preset-client#reducing-bundle-size
*/
const documents = {
"fragment BlogPageView on BlogPage {\n id\n slug\n title\n seoTitle\n thumb {\n id\n rendition(width: 1920, height: 1080, format: \"webp\") {\n id\n url\n }\n }\n}\n\nfragment BlogPageViewInner on BlogPage {\n body {\n ... on StreamFieldInterface {\n blockType\n }\n ... on RichTextBlock {\n value\n }\n ... on ImageBlock {\n caption\n link\n alignment\n image {\n url\n width\n height\n }\n }\n ... on QuoteBlock {\n quote\n attribution\n }\n ... on HeadingBlock {\n text\n importance\n }\n }\n}\n\nquery BlogListView {\n pages(contentType: \"blog.BlogPage\") {\n ...BlogPageView\n }\n}\n\nquery BlogPreviewView($token: String) {\n page(id: 0, token: $token) {\n ...BlogPageView\n ...BlogPageViewInner\n }\n}\n\nquery BlogLiveView($slug: String) {\n page(slug: $slug) {\n ...BlogPageView\n ...BlogPageViewInner\n }\n}": types.BlogPageViewFragmentDoc,
"fragment BlogPageOuterView on BlogPage {\n id\n slug\n title\n seoTitle\n thumb {\n id\n rendition(width: 1920, height: 1080, format: \"webp\") {\n id\n url\n }\n }\n}\n\nfragment BlogPageInnerView on BlogPage {\n body {\n ... on StreamFieldInterface {\n blockType\n }\n ... on RichTextBlock {\n value\n }\n ... on ImageBlock {\n caption\n link\n alignment\n image {\n url\n width\n height\n }\n }\n ... on QuoteBlock {\n quote\n attribution\n }\n ... on HeadingBlock {\n text\n importance\n }\n }\n}\n\nfragment GalleryOuterView on Picture {\n id\n cap\n image {\n id\n url\n }\n imageDate\n}\n\nquery GalleryListView {\n pages(contentType: \"gallery.Picture\") {\n ...GalleryOuterView\n }\n}\n\nquery GalleryPaginatedListView($offset: PositiveInt, $limit: PositiveInt) {\n pages(contentType: \"gallery.Picture\", offset: $offset, limit: $limit) {\n ...GalleryOuterView\n }\n}\n\nquery BlogListView {\n pages(contentType: \"blog.BlogPage\") {\n ...BlogPageOuterView\n }\n}\n\nquery BlogPaginatedListView($offset: PositiveInt, $limit: PositiveInt) {\n pages(contentType: \"blog.BlogPage\", offset: $offset, limit: $limit) {\n ...BlogPageOuterView\n }\n}\n\nquery BlogPreviewView($token: String) {\n page(id: 0, token: $token) {\n ...BlogPageOuterView\n ...BlogPageInnerView\n }\n}\n\nquery BlogLiveView($slug: String) {\n page(slug: $slug) {\n ...BlogPageOuterView\n ...BlogPageInnerView\n }\n}": types.BlogPageOuterViewFragmentDoc,
};

/**
* The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients.
*/
export function graphql(source: "fragment BlogPageView on BlogPage {\n id\n slug\n title\n seoTitle\n thumb {\n id\n rendition(width: 1920, height: 1080, format: \"webp\") {\n id\n url\n }\n }\n}\n\nfragment BlogPageViewInner on BlogPage {\n body {\n ... on StreamFieldInterface {\n blockType\n }\n ... on RichTextBlock {\n value\n }\n ... on ImageBlock {\n caption\n link\n alignment\n image {\n url\n width\n height\n }\n }\n ... on QuoteBlock {\n quote\n attribution\n }\n ... on HeadingBlock {\n text\n importance\n }\n }\n}\n\nquery BlogListView {\n pages(contentType: \"blog.BlogPage\") {\n ...BlogPageView\n }\n}\n\nquery BlogPreviewView($token: String) {\n page(id: 0, token: $token) {\n ...BlogPageView\n ...BlogPageViewInner\n }\n}\n\nquery BlogLiveView($slug: String) {\n page(slug: $slug) {\n ...BlogPageView\n ...BlogPageViewInner\n }\n}"): typeof import('./graphql').BlogPageViewFragmentDoc;
export function graphql(source: "fragment BlogPageOuterView on BlogPage {\n id\n slug\n title\n seoTitle\n thumb {\n id\n rendition(width: 1920, height: 1080, format: \"webp\") {\n id\n url\n }\n }\n}\n\nfragment BlogPageInnerView on BlogPage {\n body {\n ... on StreamFieldInterface {\n blockType\n }\n ... on RichTextBlock {\n value\n }\n ... on ImageBlock {\n caption\n link\n alignment\n image {\n url\n width\n height\n }\n }\n ... on QuoteBlock {\n quote\n attribution\n }\n ... on HeadingBlock {\n text\n importance\n }\n }\n}\n\nfragment GalleryOuterView on Picture {\n id\n cap\n image {\n id\n url\n }\n imageDate\n}\n\nquery GalleryListView {\n pages(contentType: \"gallery.Picture\") {\n ...GalleryOuterView\n }\n}\n\nquery GalleryPaginatedListView($offset: PositiveInt, $limit: PositiveInt) {\n pages(contentType: \"gallery.Picture\", offset: $offset, limit: $limit) {\n ...GalleryOuterView\n }\n}\n\nquery BlogListView {\n pages(contentType: \"blog.BlogPage\") {\n ...BlogPageOuterView\n }\n}\n\nquery BlogPaginatedListView($offset: PositiveInt, $limit: PositiveInt) {\n pages(contentType: \"blog.BlogPage\", offset: $offset, limit: $limit) {\n ...BlogPageOuterView\n }\n}\n\nquery BlogPreviewView($token: String) {\n page(id: 0, token: $token) {\n ...BlogPageOuterView\n ...BlogPageInnerView\n }\n}\n\nquery BlogLiveView($slug: String) {\n page(slug: $slug) {\n ...BlogPageOuterView\n ...BlogPageInnerView\n }\n}"): typeof import('./graphql').BlogPageOuterViewFragmentDoc;


export function graphql(source: string) {
Expand Down
Loading

0 comments on commit d67628e

Please sign in to comment.