Skip to content

Commit

Permalink
Use graphql directives
Browse files Browse the repository at this point in the history
  • Loading branch information
soniaklimas committed Dec 24, 2024
1 parent 6022e6d commit 6f48b2d
Show file tree
Hide file tree
Showing 7 changed files with 215 additions and 441 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fragment PageInfoFragment on PageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type * as Types from '@nimara/codegen/schema';

import type { DocumentTypeDecoration } from '@graphql-typed-document-node/core';
export type PageInfoFragment = { startCursor: string | null, endCursor: string | null, hasNextPage: boolean, hasPreviousPage: boolean };

export type SearchProductFragment_Product_translation_ProductTranslation = { name: string | null };

export type SearchProductFragment_Product_thumbnail_Image = { url: string, alt: string | null };
Expand Down Expand Up @@ -47,6 +49,14 @@ export class TypedDocumentString<TResult, TVariables>
return this.value;
}
}
export const PageInfoFragment = new TypedDocumentString(`
fragment PageInfoFragment on PageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
`, {"fragmentName":"PageInfoFragment"}) as unknown as TypedDocumentString<PageInfoFragment, unknown>;
export const SearchProductFragment = new TypedDocumentString(`
fragment SearchProductFragment on Product {
id
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,104 @@
# query SearchProductQuery(
# $after: String
# $before: String
# $channel: String!
# $filter: ProductFilterInput
# $first: Int
# $last: Int
# $search: String
# $sortBy: ProductOrder
# $languageCode: LanguageCodeEnum!
# $where: ProductWhereInput
# ) {
# products(
# after: $after
# before: $before
# channel: $channel
# filter: $filter
# first: $first
# last: $last
# search: $search
# sortBy: $sortBy
# where: $where
# ) {
# edges {
# node {
# ...SearchProductFragment
# }
# }
# pageInfo {
# startCursor
# endCursor
# hasNextPage
# hasPreviousPage
# }
# totalCount
# }
# }

query SearchProductQuery(
$after: String
$before: String
$categorySlug: String
$channel: String!
$collectionSlug: String
$filter: ProductFilterInput
$first: Int
$languageCode: LanguageCodeEnum!
$last: Int
$search: String
$searchByCategory: Boolean!
$searchByCollection: Boolean!
$searchByProducts: Boolean!
$sortBy: ProductOrder
$languageCode: LanguageCodeEnum!
$where: ProductWhereInput
) {
category(slug: $categorySlug) @include(if: $searchByCategory) {
products(
after: $after
before: $before
channel: $channel
filter: $filter
first: $first
last: $last
sortBy: $sortBy
where: $where
) {
edges {
node {
...SearchProductFragment
}
}
pageInfo {
...PageInfoFragment
}
totalCount
}
}

collection(slug: $collectionSlug, channel: $channel)
@include(if: $searchByCollection) {
products(
after: $after
before: $before
filter: $filter
first: $first
last: $last
sortBy: $sortBy
where: $where
) {
edges {
node {
...SearchProductFragment
}
}
pageInfo {
...PageInfoFragment
}
totalCount
}
}

products(
after: $after
before: $before
Expand All @@ -20,17 +109,14 @@ query SearchProductQuery(
search: $search
sortBy: $sortBy
where: $where
) {
) @include(if: $searchByProducts) {
edges {
node {
...SearchProductFragment
}
}
pageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
...PageInfoFragment
}
totalCount
}
Expand Down
Loading

0 comments on commit 6f48b2d

Please sign in to comment.