-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,707 additions
and
594 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
query InitialQuery($first: Int!, $after: String=null) { | ||
shop { | ||
name | ||
description | ||
url | ||
} | ||
products(first: $first, after: $after) { | ||
...SelectProducts | ||
} | ||
} | ||
|
||
query LoadProducts($first: Int!, $after: String!) { | ||
products(first: $first, after: $after) { | ||
...SelectProducts | ||
} | ||
} | ||
|
||
fragment SelectProducts on ProductConnection { | ||
pageInfo { hasNextPage } | ||
edges { | ||
cursor | ||
node { | ||
id | ||
handle | ||
description | ||
title | ||
totalInventory | ||
priceRangeV2 { | ||
minVariantPrice { | ||
...Money | ||
} | ||
maxVariantPrice { | ||
...Money | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
fragment Money on MoneyV2 { | ||
amount | ||
currencyCode | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import sgqlc.types | ||
import sgqlc.operation | ||
import shopify_schema | ||
|
||
__all__ = ('Operations',) | ||
|
||
|
||
def fragment_select_products(): | ||
_frag = sgqlc.operation.Fragment(shopify_schema.ProductConnection, 'SelectProducts') | ||
_frag_page_info = _frag.page_info() | ||
_frag_page_info.has_next_page() | ||
_frag_edges = _frag.edges() | ||
_frag_edges.cursor() | ||
_frag_edges_node = _frag_edges.node() | ||
_frag_edges_node.id() | ||
_frag_edges_node.handle() | ||
_frag_edges_node.description() | ||
_frag_edges_node.title() | ||
_frag_edges_node.total_inventory() | ||
_frag_edges_node_price_range_v2 = _frag_edges_node.price_range_v2() | ||
_frag_edges_node_price_range_v2_min_variant_price = _frag_edges_node_price_range_v2.min_variant_price() | ||
_frag_edges_node_price_range_v2_min_variant_price.__fragment__(fragment_money()) | ||
_frag_edges_node_price_range_v2_max_variant_price = _frag_edges_node_price_range_v2.max_variant_price() | ||
_frag_edges_node_price_range_v2_max_variant_price.__fragment__(fragment_money()) | ||
return _frag | ||
|
||
|
||
def fragment_money(): | ||
_frag = sgqlc.operation.Fragment(shopify_schema.MoneyV2, 'Money') | ||
_frag.amount() | ||
_frag.currency_code() | ||
return _frag | ||
|
||
|
||
class Fragment: | ||
money = fragment_money() | ||
select_products = fragment_select_products() | ||
|
||
|
||
def query_initial_query(): | ||
_op = sgqlc.operation.Operation(shopify_schema.shopify_schema.query_type, name='InitialQuery', first=sgqlc.types.Arg(sgqlc.types.non_null(shopify_schema.shopify_schema.Int)), after=sgqlc.types.Arg(shopify_schema.shopify_schema.String, default=None)) | ||
_op_shop = _op.shop() | ||
_op_shop.name() | ||
_op_shop.description() | ||
_op_shop.url() | ||
_op_products = _op.products(first=sgqlc.types.Variable('first'), after=sgqlc.types.Variable('after')) | ||
_op_products.__fragment__(fragment_select_products()) | ||
return _op | ||
|
||
|
||
def query_load_products(): | ||
_op = sgqlc.operation.Operation(shopify_schema.shopify_schema.query_type, name='LoadProducts', first=sgqlc.types.Arg(sgqlc.types.non_null(shopify_schema.shopify_schema.Int)), after=sgqlc.types.Arg(sgqlc.types.non_null(shopify_schema.shopify_schema.String))) | ||
_op_products = _op.products(first=sgqlc.types.Variable('first'), after=sgqlc.types.Variable('after')) | ||
_op_products.__fragment__(fragment_select_products()) | ||
return _op | ||
|
||
|
||
class Query: | ||
initial_query = query_initial_query() | ||
load_products = query_load_products() | ||
|
||
|
||
class Operations: | ||
fragment = Fragment | ||
query = Query |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
sgqlc-codegen operation \ | ||
--schema shopify_schema.json \ | ||
shopify_schema \ | ||
shopify_operations.py \ | ||
shopify_operations.gql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.