refactor: rename gql documents

This commit is contained in:
Zotov Ivan Yuryevich
2026-04-14 23:25:04 +03:00
parent 32ea9359ae
commit 31ee186d22
10 changed files with 39 additions and 39 deletions

View File

@@ -1,8 +1,8 @@
import gql from "graphql-tag"; import gql from 'graphql-tag'
export const categoriesListDocument = gql` export const categoriesListDocument = gql`
query CategoriesList { query CategoriesList($group: String) {
categories { categories(filters: { group: { eq: $group } }) {
documentId documentId
slug slug
title title
@@ -11,4 +11,4 @@ export const categoriesListDocument = gql`
badge badge
} }
} }
`; `

View File

@@ -3,11 +3,11 @@
import type { ExecutionResult } from "graphql"; import type { ExecutionResult } from "graphql";
import { execute } from "../graphql/execute"; import { execute } from "../graphql/execute";
import type { HomePageQueryQuery, HomePageQueryQueryVariables } from "../graphql/graphql"; import type { HomePageQuery, HomePageQueryVariables } from "../graphql/graphql";
import { homePageDocument } from "./home-page.gql"; import { homePageDocument } from "./home-page.gql";
export const homePageQueryQuery = { export const homePageQuery = {
async execute(variables?: HomePageQueryQueryVariables): Promise<ExecutionResult<HomePageQueryQuery>> { async execute(variables?: HomePageQueryVariables): Promise<ExecutionResult<HomePageQuery>> {
return execute<HomePageQueryQuery, HomePageQueryQueryVariables>(homePageDocument, variables); return execute<HomePageQuery, HomePageQueryVariables>(homePageDocument, variables);
}, },
}; };

View File

@@ -1,7 +1,7 @@
import gql from 'graphql-tag' import gql from 'graphql-tag'
export const homePageDocument = gql` export const homePageDocument = gql`
query HomePageQuery { query HomePage {
homePage { homePage {
sections { sections {
__typename __typename

View File

@@ -3,11 +3,11 @@
import type { ExecutionResult } from "graphql"; import type { ExecutionResult } from "graphql";
import { execute } from "../graphql/execute"; import { execute } from "../graphql/execute";
import type { SiteConfigQueryQuery, SiteConfigQueryQueryVariables } from "../graphql/graphql"; import type { SiteConfigQuery, SiteConfigQueryVariables } from "../graphql/graphql";
import { siteConfigDocument } from "./site-config.gql"; import { siteConfigDocument } from "./site-config.gql";
export const siteConfigQueryQuery = { export const siteConfigQuery = {
async execute(variables?: SiteConfigQueryQueryVariables): Promise<ExecutionResult<SiteConfigQueryQuery>> { async execute(variables?: SiteConfigQueryVariables): Promise<ExecutionResult<SiteConfigQuery>> {
return execute<SiteConfigQueryQuery, SiteConfigQueryQueryVariables>(siteConfigDocument, variables); return execute<SiteConfigQuery, SiteConfigQueryVariables>(siteConfigDocument, variables);
}, },
}; };

View File

@@ -1,7 +1,7 @@
import gql from 'graphql-tag' import gql from 'graphql-tag'
export const siteConfigDocument = gql` export const siteConfigDocument = gql`
query SiteConfigQuery { query SiteConfig {
siteConfig { siteConfig {
title title
description description

View File

@@ -1554,15 +1554,17 @@ export type VendorRelationResponseCollection = {
nodes: Array<Vendor>; nodes: Array<Vendor>;
}; };
export type CategoriesListQueryVariables = Exact<{ [key: string]: never; }>; export type CategoriesListQueryVariables = Exact<{
group?: InputMaybe<Scalars['String']['input']>;
}>;
export type CategoriesListQuery = { __typename?: 'Query', categories: Array<{ __typename?: 'Category', documentId: string, slug: string, title?: string | null, sortOrder: number, group: Enum_Category_Group, badge?: string | null } | null> }; export type CategoriesListQuery = { __typename?: 'Query', categories: Array<{ __typename?: 'Category', documentId: string, slug: string, title?: string | null, sortOrder: number, group: Enum_Category_Group, badge?: string | null } | null> };
export type HomePageQueryQueryVariables = Exact<{ [key: string]: never; }>; export type HomePageQueryVariables = Exact<{ [key: string]: never; }>;
export type HomePageQueryQuery = { __typename?: 'Query', homePage?: { __typename?: 'HomePage', sections?: Array< export type HomePageQuery = { __typename?: 'Query', homePage?: { __typename?: 'HomePage', sections?: Array<
| { __typename: 'ComponentSectionsAbout', id: string, title?: string | null, description?: string | null, partners?: Array<{ __typename?: 'ComponentSharedString', id: string, value: string } | null> | null, cards?: Array<{ __typename?: 'ComponentCardsAdvantage', id: string, title?: string | null, description?: string | null, color?: { __typename?: 'ComponentSharedColor', value?: Enum_Componentsharedcolor_Value | null } | null, icon?: { __typename?: 'ComponentSharedIcon', value?: Enum_Componentsharedicon_Value | null } | null } | null> | null } | { __typename: 'ComponentSectionsAbout', id: string, title?: string | null, description?: string | null, partners?: Array<{ __typename?: 'ComponentSharedString', id: string, value: string } | null> | null, cards?: Array<{ __typename?: 'ComponentCardsAdvantage', id: string, title?: string | null, description?: string | null, color?: { __typename?: 'ComponentSharedColor', value?: Enum_Componentsharedcolor_Value | null } | null, icon?: { __typename?: 'ComponentSharedIcon', value?: Enum_Componentsharedicon_Value | null } | null } | null> | null }
| { __typename: 'ComponentSectionsCases', id: string, title?: string | null, description?: string | null, cards?: Array<{ __typename?: 'ComponentCardsCase', id: string, title?: string | null, description?: string | null, pretitle?: string | null, badge?: string | null, footnote?: string | null, color?: { __typename?: 'ComponentSharedColor', value?: Enum_Componentsharedcolor_Value | null } | null, icon?: { __typename?: 'ComponentSharedIcon', value?: Enum_Componentsharedicon_Value | null } | null } | null> | null } | { __typename: 'ComponentSectionsCases', id: string, title?: string | null, description?: string | null, cards?: Array<{ __typename?: 'ComponentCardsCase', id: string, title?: string | null, description?: string | null, pretitle?: string | null, badge?: string | null, footnote?: string | null, color?: { __typename?: 'ComponentSharedColor', value?: Enum_Componentsharedcolor_Value | null } | null, icon?: { __typename?: 'ComponentSharedIcon', value?: Enum_Componentsharedicon_Value | null } | null } | null> | null }
| { __typename: 'ComponentSectionsHomeHero', id: string, title?: string | null, description?: string | null, badge?: string | null, stats?: Array<{ __typename?: 'ComponentSharedAttribute', id: string, key?: string | null, value?: string | null } | null> | null } | { __typename: 'ComponentSectionsHomeHero', id: string, title?: string | null, description?: string | null, badge?: string | null, stats?: Array<{ __typename?: 'ComponentSharedAttribute', id: string, key?: string | null, value?: string | null } | null> | null }
@@ -1571,10 +1573,10 @@ export type HomePageQueryQuery = { __typename?: 'Query', homePage?: { __typename
| { __typename: 'Error' } | { __typename: 'Error' }
| null> | null } | null }; | null> | null } | null };
export type SiteConfigQueryQueryVariables = Exact<{ [key: string]: never; }>; export type SiteConfigQueryVariables = Exact<{ [key: string]: never; }>;
export type SiteConfigQueryQuery = { __typename?: 'Query', siteConfig?: { __typename?: 'SiteConfig', title: string, description?: string | null, contacts?: Array<{ __typename?: 'ComponentSharedContact', id: string, type: Enum_Componentsharedcontact_Type, value: string, displayValue?: string | null } | null> | null } | null }; export type SiteConfigQuery = { __typename?: 'Query', siteConfig?: { __typename?: 'SiteConfig', title: string, description?: string | null, contacts?: Array<{ __typename?: 'ComponentSharedContact', id: string, type: Enum_Componentsharedcontact_Type, value: string, displayValue?: string | null } | null> | null } | null };
export class TypedDocumentString<TResult, TVariables> export class TypedDocumentString<TResult, TVariables>
extends String extends String
@@ -1596,8 +1598,8 @@ export class TypedDocumentString<TResult, TVariables>
} }
export const CategoriesListDocument = new TypedDocumentString(` export const CategoriesListDocument = new TypedDocumentString(`
query CategoriesList { query CategoriesList($group: String) {
categories { categories(filters: {group: {eq: $group}}) {
documentId documentId
slug slug
title title
@@ -1607,8 +1609,8 @@ export const CategoriesListDocument = new TypedDocumentString(`
} }
} }
`) as unknown as TypedDocumentString<CategoriesListQuery, CategoriesListQueryVariables>; `) as unknown as TypedDocumentString<CategoriesListQuery, CategoriesListQueryVariables>;
export const HomePageQueryDocument = new TypedDocumentString(` export const HomePageDocument = new TypedDocumentString(`
query HomePageQuery { query HomePage {
homePage { homePage {
sections { sections {
__typename __typename
@@ -1701,9 +1703,9 @@ export const HomePageQueryDocument = new TypedDocumentString(`
} }
} }
} }
`) as unknown as TypedDocumentString<HomePageQueryQuery, HomePageQueryQueryVariables>; `) as unknown as TypedDocumentString<HomePageQuery, HomePageQueryVariables>;
export const SiteConfigQueryDocument = new TypedDocumentString(` export const SiteConfigDocument = new TypedDocumentString(`
query SiteConfigQuery { query SiteConfig {
siteConfig { siteConfig {
title title
description description
@@ -1715,4 +1717,4 @@ export const SiteConfigQueryDocument = new TypedDocumentString(`
} }
} }
} }
`) as unknown as TypedDocumentString<SiteConfigQueryQuery, SiteConfigQueryQueryVariables>; `) as unknown as TypedDocumentString<SiteConfigQuery, SiteConfigQueryVariables>;

View File

@@ -1,5 +1,3 @@
import type { SiteConfigQueryQuery } from '../../../graphql/graphql' import type { SiteConfigQuery } from '../../../graphql/graphql'
export type SiteConfigContact = NonNullable< export type SiteConfigContact = NonNullable<NonNullable<NonNullable<SiteConfigQuery['siteConfig']>['contacts']>[number]>
NonNullable<NonNullable<SiteConfigQueryQuery['siteConfig']>['contacts']>[number]
>

View File

@@ -6,11 +6,11 @@ import { Header } from '../sections/Header'
import { Footer } from '../sections/Footer' import { Footer } from '../sections/Footer'
import { CategoryView } from '../views/CategoryView' import { CategoryView } from '../views/CategoryView'
import type { SiteConfigContact } from '../lib/cms/contact/types' import type { SiteConfigContact } from '../lib/cms/contact/types'
import { siteConfigQueryQuery } from '../graphql-documents/site-config.gql.generated' import { siteConfigQuery } from '../graphql-documents/site-config.gql.generated'
export async function getStaticPaths() { export async function getStaticPaths() {
const categories = await getCollection('categories') const categories = await getCollection('categories')
const siteResult = await siteConfigQueryQuery.execute() const siteResult = await siteConfigQuery.execute()
if (siteResult.errors?.length) { if (siteResult.errors?.length) {
throw new Error(siteResult.errors.map(e => e.message).join(', ')) throw new Error(siteResult.errors.map(e => e.message).join(', '))
} }

View File

@@ -4,12 +4,12 @@ import '../styles/globals.css'
import { Header } from '../sections/Header' import { Header } from '../sections/Header'
import { Footer } from '../sections/Footer' import { Footer } from '../sections/Footer'
import { HomePage } from '../views/HomePage' import { HomePage } from '../views/HomePage'
import { homePageQueryQuery } from '../graphql-documents/home-page.gql.generated' import { homePageQuery } from '../graphql-documents/home-page.gql.generated'
import { siteConfigQueryQuery } from '../graphql-documents/site-config.gql.generated' import { siteConfigQuery } from '../graphql-documents/site-config.gql.generated'
const [homeResult, siteResult] = await Promise.all([ const [homeResult, siteResult] = await Promise.all([
homePageQueryQuery.execute(), homePageQuery.execute(),
siteConfigQueryQuery.execute(), siteConfigQuery.execute(),
]) ])
if (homeResult.errors?.length) { if (homeResult.errors?.length) {

View File

@@ -1,5 +1,5 @@
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import type { HomePageQueryQuery } from '../graphql/graphql' import type { HomePageQuery } from '../graphql/graphql'
import { Hero } from '../sections/Hero' import { Hero } from '../sections/Hero'
import { Services } from '../sections/Services' import { Services } from '../sections/Services'
import { Solutions } from '../sections/Solutions' import { Solutions } from '../sections/Solutions'
@@ -13,7 +13,7 @@ import type { Maybe } from '../lib/types'
const HEADER_OFFSET_PX = 85 const HEADER_OFFSET_PX = 85
type HomePageData = NonNullable<HomePageQueryQuery['homePage']> type HomePageData = NonNullable<HomePageQuery['homePage']>
type HomeSection = NonNullable<NonNullable<HomePageData['sections']>[number]> type HomeSection = NonNullable<NonNullable<HomePageData['sections']>[number]>
type HeroSection = Extract<HomeSection, { __typename?: 'ComponentSectionsHomeHero' }> type HeroSection = Extract<HomeSection, { __typename?: 'ComponentSectionsHomeHero' }>