✨ Register: Show list of active products
🛠 Generate apollo client typescript helpers from graphql schema
This commit is contained in:
1 parent
fa89353525
commit
f0656b34e9
13 files changed
+8165
-173
No files matched your search
@@ -0,0 +1,17 @@
|
||||
import React from "react";
|
||||
|
||||
import {Product, useAllProductsQuery} from '../types';
|
||||
|
||||
export const Register: React.FC = () => {
|
||||
const { data, error, loading } = useAllProductsQuery({variables:{active: true}});
|
||||
if(error) {
|
||||
console.log('🔥', error)
|
||||
return null;
|
||||
}
|
||||
if(loading) {
|
||||
return <div>...</div>
|
||||
}
|
||||
return (<div>{data?.allProducts.map((product: Product) => {
|
||||
return <div key={product.id}>{product.name}</div>
|
||||
})} </div>)
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
query allProducts($active: Boolean!) {
|
||||
allProducts(filters: {active: $active}) {
|
||||
id
|
||||
name
|
||||
salePriceExt
|
||||
salePriceInt
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user