Example Storefront is Reaction Commerce’s headless ecommerce storefront - Next.js, GraphQL, React. Built using Apollo Client and the commerce-focused React UI components provided in the Storefront Component Library (reactioncommerce/reaction-component-library). It connects with Reaction backend with the GraphQL API.
Summary
Create a query to retreive tags associated with navigation in GraphQL for the provided shop.
Implementation
Schema
type Tag implements Node, Deletable {
_id: ID!
name: String!
slug: String
# type: String # OMIT: Introduced for Foray?
metafields: [Metafield]
position: Int
relatedTags: [TagConnection]
isDeleted: Boolean!
isTopLevel: Boolean!
#isVisible: Boolean! # OMIT: This is not editable or used. Keep in db but don't expose over Graphql.
#groups: [String] # OMIT: Not used in core. Limits visibility to groups.
shop: Shop!
createdAt: DateTime!
updatedAt: DateTime!
}
enum TagSortByField {
_id
name
createdAt
updatedAt
}
type TagEdge implements NodeEdge {
cursor: ConnectionCursor!
node: Tag
}
type TagConnection implements NodeConnection {
edges: [TagEdge]
nodes: [Tag]
pageInfo: PageInfo!
totalCount: Int!
}
Query
The root navigationTags query should have the following signature
# Returns a paged list of tags for a shop
tags(shopId: ID!, isTopLevel: Boolean, sortOrder: SortOrder = asc, sortBy: TagSortByField = createdAt): TagConnection
Also create a similar query within the Shop type
# Returns a paged list of tags for this shop
tags(isTopLevel: Boolean, sortOrder: SortOrder = asc, sortBy: TagSortByField = createdAt): TagConnection
Both queries return a TagConnection filtered by the arguments provided.
You'll need to implement Tag.relatedTags as a separate resolver. Figure out a way to throw an error if more than 1 level of relatedTags is requested.
Acceptance Criteria
Using GraphQL, I can use the tags(shopId: ID!, isTopLevel: Boolean) query to get a TagConnection for a specific shop.
Using GraphQL, I can use the Shop.tags(isTopLevel: Boolean) query to get a TagConnection for the parent shop
Either query can specify relatedTags and get at most one level of related tags.
@spencern commented on Fri Mar 30 2018
Summary Create a query to retreive tags associated with navigation in GraphQL for the provided shop.
Implementation
Schema
Query
The root navigationTags query should have the following signature
Also create a similar query within the
Shop
typeBoth queries return a TagConnection filtered by the arguments provided.
You'll need to implement
Tag.relatedTags
as a separate resolver. Figure out a way to throw an error if more than 1 level ofrelatedTags
is requested.Acceptance Criteria
relatedTags
and get at most one level of related tags.