diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-11-27 19:38:32 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-27 20:06:56 +0100 |
| commit | ff79add1d59375817a10331a35458cca3c419cfe (patch) | |
| tree | 5e678e2c3cd43ace5cb7fd27a22f6e8403ccd211 /tests/msw/schema/types | |
| parent | f111685c5886f3e77edfd3621c98d8ac1b9bcce4 (diff) | |
test: add MSW to intercept GraphQL requests
Diffstat (limited to 'tests/msw/schema/types')
| -rw-r--r-- | tests/msw/schema/types/author.types.ts | 26 | ||||
| -rw-r--r-- | tests/msw/schema/types/common.types.ts | 36 | ||||
| -rw-r--r-- | tests/msw/schema/types/featured-image.types.ts | 24 | ||||
| -rw-r--r-- | tests/msw/schema/types/index.ts | 26 | ||||
| -rw-r--r-- | tests/msw/schema/types/post.types.ts | 72 | ||||
| -rw-r--r-- | tests/msw/schema/types/thematic.types.ts | 20 | ||||
| -rw-r--r-- | tests/msw/schema/types/topic.types.ts | 21 |
7 files changed, 225 insertions, 0 deletions
diff --git a/tests/msw/schema/types/author.types.ts b/tests/msw/schema/types/author.types.ts new file mode 100644 index 0000000..bbb50a4 --- /dev/null +++ b/tests/msw/schema/types/author.types.ts @@ -0,0 +1,26 @@ +export const authorTypes = `enum AvatarRatingEnum { + G + PG + R + X +} + +type Avatar { + height: Int + url: String + width: Int +} + +type User { + avatar( + forceDefault: Boolean + rating: AvatarRatingEnum + size: Int = 96 + ): Avatar + databaseId: Int! + name: String + url: String +} +type NodeWithAuthorToUserConnectionEdge { + node: User! +}`; diff --git a/tests/msw/schema/types/common.types.ts b/tests/msw/schema/types/common.types.ts new file mode 100644 index 0000000..23baeb3 --- /dev/null +++ b/tests/msw/schema/types/common.types.ts @@ -0,0 +1,36 @@ +export const commonTypes = `enum PostObjectFieldFormatEnum { + RAW + RENDERED +} + +enum OrderEnum { + ASC + DESC +} + +enum PostObjectsConnectionOrderbyEnum { + AUTHOR + COMMENT_COUNT + DATE + IN + MENU_ORDER + MODIFIED + NAME_IN + PARENT + SLUG + TITLE +} + +type ContentPartsType { + afterMore(format: PostObjectFieldFormatEnum): String + beforeMore(format: PostObjectFieldFormatEnum): String +} + +type InfoType { + wordsCount: Int +} + +type PostTypeSEO { + metaDesc: String + title: String +}`; diff --git a/tests/msw/schema/types/featured-image.types.ts b/tests/msw/schema/types/featured-image.types.ts new file mode 100644 index 0000000..788da5f --- /dev/null +++ b/tests/msw/schema/types/featured-image.types.ts @@ -0,0 +1,24 @@ +export const featuredImageTypes = `type MediaDetails { + height: Int + width: Int +} + +enum MediaItemSizeEnum { + LARGE + MEDIUM + MEDIUM_LARGE + THUMBNAIL + _1536X1536 + _2048X2048 +} + +type MediaItem { + altText: String + mediaDetails: MediaDetails + sourceUrl(size: MediaItemSizeEnum): String + title(format: PostObjectFieldFormatEnum): String +} + +type NodeWithFeaturedImageToMediaItemConnectionEdge { + node: MediaItem! +}`; diff --git a/tests/msw/schema/types/index.ts b/tests/msw/schema/types/index.ts new file mode 100644 index 0000000..ea749be --- /dev/null +++ b/tests/msw/schema/types/index.ts @@ -0,0 +1,26 @@ +import { authorTypes } from './author.types'; +import { commonTypes } from './common.types'; +import { featuredImageTypes } from './featured-image.types'; +import { postTypes } from './post.types'; +import { thematicTypes } from './thematic.types'; +import { topicTypes } from './topic.types'; + +const rootQueryType = `type Query { + posts( + after: String + before: String + first: Int + last: Int + where: RootQueryToPostConnectionWhereArgs + ): RootQueryToPostConnection +}`; + +export const types = [ + authorTypes, + commonTypes, + featuredImageTypes, + postTypes, + thematicTypes, + topicTypes, + rootQueryType, +]; diff --git a/tests/msw/schema/types/post.types.ts b/tests/msw/schema/types/post.types.ts new file mode 100644 index 0000000..04c4f37 --- /dev/null +++ b/tests/msw/schema/types/post.types.ts @@ -0,0 +1,72 @@ +export const postTypes = `union Post_Acfposts_PostsInThematic = Thematic + +union Post_Acfposts_PostsInTopic = Topic + +type Post_Acfposts { + postsInThematic: [Post_Acfposts_PostsInThematic] + postsInTopic: [Post_Acfposts_PostsInTopic] +} + +type Post { + acfPosts: Post_Acfposts + author: NodeWithAuthorToUserConnectionEdge + commentCount: Int + contentParts: ContentPartsType + databaseId: Int! + date: String + featuredImage: NodeWithFeaturedImageToMediaItemConnectionEdge + info: InfoType + modified: String! + seo: PostTypeSEO + slug: String + title(format: PostObjectFieldFormatEnum): String +} + +enum PostStatusEnum { + ACF_DISABLED + AUTO_DRAFT + DRAFT + FUTURE + INHERIT + PENDING + PRIVATE + PUBLISH + REQUEST_COMPLETED + REQUEST_CONFIRMED + REQUEST_FAILED + REQUEST_PENDING + TRASH +} + +input PostObjectsConnectionOrderbyInput { + field: PostObjectsConnectionOrderbyEnum! + order: OrderEnum! +} + +input RootQueryToPostConnectionWhereArgs { + authorName: String + orderby: [PostObjectsConnectionOrderbyInput] + search: String + status: PostStatusEnum + title: String +} + +type RootQueryToPostConnectionEdge { + cursor: String + node: Post! +} + +type RootQueryToPostConnectionPageInfo { + endCursor: String + hasNextPage: Boolean! + hasPreviousPage: Boolean! + startCursor: String + total: Int +} + +type RootQueryToPostConnection { + edges: [RootQueryToPostConnectionEdge!]! + pageInfo: RootQueryToPostConnectionPageInfo! +}`; + +// cSpell:ignore Acfposts diff --git a/tests/msw/schema/types/thematic.types.ts b/tests/msw/schema/types/thematic.types.ts new file mode 100644 index 0000000..afa95c9 --- /dev/null +++ b/tests/msw/schema/types/thematic.types.ts @@ -0,0 +1,20 @@ +export const thematicTypes = `union Thematic_Acfthematics_PostsInThematic = Post + +type Thematic_Acfthematics { + postsInThematic: [Thematic_Acfthematics_PostsInThematic] +} + +type Thematic { + acfThematics: Thematic_Acfthematics + contentParts: ContentPartsType + databaseId: Int! + date: String + featuredImage: NodeWithFeaturedImageToMediaItemConnectionEdge + info: InfoType + modified: String + seo: PostTypeSEO + slug: String + title(format: PostObjectFieldFormatEnum): String +}`; + +// cSpell:ignore Acfthematics diff --git a/tests/msw/schema/types/topic.types.ts b/tests/msw/schema/types/topic.types.ts new file mode 100644 index 0000000..ba9abb7 --- /dev/null +++ b/tests/msw/schema/types/topic.types.ts @@ -0,0 +1,21 @@ +export const topicTypes = `union Topic_Acftopics_PostsInTopic = Post + +type Topic_Acftopics { + officialWebsite: String + postsInTopic: [Topic_Acftopics_PostsInTopic] +} + +type Topic { + acfTopics: Topic_Acftopics + contentParts: ContentPartsType + databaseId: Int! + date: String + featuredImage: NodeWithFeaturedImageToMediaItemConnectionEdge + info: InfoType + modified: String + seo: PostTypeSEO + slug: String + title(format: PostObjectFieldFormatEnum): String +}`; + +// cSpell:ignore Acftopics |
