Skip to content

Commit 5f2d4ba

Browse files
committed
stepped solutions
1 parent 8d4dffa commit 5f2d4ba

File tree

13 files changed

+2344
-25
lines changed

13 files changed

+2344
-25
lines changed

finished-application/backend/src/generated/prisma.graphql

+35-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# source: https://us1.prisma.sh/wesbos/sick-fits/dev
2-
# timestamp: Mon Jun 18 2018 16:08:08 GMT-0400 (EDT)
2+
# timestamp: Thu Jun 21 2018 15:13:13 GMT-0400 (EDT)
33

44
type AggregateCartItem {
55
count: Int!
@@ -705,6 +705,9 @@ input ItemWhereInput {
705705
"""All values greater than or equal the given value."""
706706
updatedAt_gte: DateTime
707707
user: UserWhereInput
708+
_MagicalBackRelation_CartItemToItem_every: CartItemWhereInput
709+
_MagicalBackRelation_CartItemToItem_some: CartItemWhereInput
710+
_MagicalBackRelation_CartItemToItem_none: CartItemWhereInput
708711
}
709712

710713
input ItemWhereUniqueInput {
@@ -718,36 +721,36 @@ Long can represent values between -(2^63) and 2^63 - 1.
718721
scalar Long
719722

720723
type Mutation {
721-
createUser(data: UserCreateInput!): User!
722724
createCartItem(data: CartItemCreateInput!): CartItem!
725+
createOrder(data: OrderCreateInput!): Order!
726+
createUser(data: UserCreateInput!): User!
723727
createItem(data: ItemCreateInput!): Item!
724728
createOrderItem(data: OrderItemCreateInput!): OrderItem!
725-
createOrder(data: OrderCreateInput!): Order!
726-
updateUser(data: UserUpdateInput!, where: UserWhereUniqueInput!): User
727729
updateCartItem(data: CartItemUpdateInput!, where: CartItemWhereUniqueInput!): CartItem
730+
updateOrder(data: OrderUpdateInput!, where: OrderWhereUniqueInput!): Order
731+
updateUser(data: UserUpdateInput!, where: UserWhereUniqueInput!): User
728732
updateItem(data: ItemUpdateInput!, where: ItemWhereUniqueInput!): Item
729733
updateOrderItem(data: OrderItemUpdateInput!, where: OrderItemWhereUniqueInput!): OrderItem
730-
updateOrder(data: OrderUpdateInput!, where: OrderWhereUniqueInput!): Order
731-
deleteUser(where: UserWhereUniqueInput!): User
732734
deleteCartItem(where: CartItemWhereUniqueInput!): CartItem
735+
deleteOrder(where: OrderWhereUniqueInput!): Order
736+
deleteUser(where: UserWhereUniqueInput!): User
733737
deleteItem(where: ItemWhereUniqueInput!): Item
734738
deleteOrderItem(where: OrderItemWhereUniqueInput!): OrderItem
735-
deleteOrder(where: OrderWhereUniqueInput!): Order
736-
upsertUser(where: UserWhereUniqueInput!, create: UserCreateInput!, update: UserUpdateInput!): User!
737739
upsertCartItem(where: CartItemWhereUniqueInput!, create: CartItemCreateInput!, update: CartItemUpdateInput!): CartItem!
740+
upsertOrder(where: OrderWhereUniqueInput!, create: OrderCreateInput!, update: OrderUpdateInput!): Order!
741+
upsertUser(where: UserWhereUniqueInput!, create: UserCreateInput!, update: UserUpdateInput!): User!
738742
upsertItem(where: ItemWhereUniqueInput!, create: ItemCreateInput!, update: ItemUpdateInput!): Item!
739743
upsertOrderItem(where: OrderItemWhereUniqueInput!, create: OrderItemCreateInput!, update: OrderItemUpdateInput!): OrderItem!
740-
upsertOrder(where: OrderWhereUniqueInput!, create: OrderCreateInput!, update: OrderUpdateInput!): Order!
741-
updateManyUsers(data: UserUpdateInput!, where: UserWhereInput): BatchPayload!
742744
updateManyCartItems(data: CartItemUpdateInput!, where: CartItemWhereInput): BatchPayload!
745+
updateManyOrders(data: OrderUpdateInput!, where: OrderWhereInput): BatchPayload!
746+
updateManyUsers(data: UserUpdateInput!, where: UserWhereInput): BatchPayload!
743747
updateManyItems(data: ItemUpdateInput!, where: ItemWhereInput): BatchPayload!
744748
updateManyOrderItems(data: OrderItemUpdateInput!, where: OrderItemWhereInput): BatchPayload!
745-
updateManyOrders(data: OrderUpdateInput!, where: OrderWhereInput): BatchPayload!
746-
deleteManyUsers(where: UserWhereInput): BatchPayload!
747749
deleteManyCartItems(where: CartItemWhereInput): BatchPayload!
750+
deleteManyOrders(where: OrderWhereInput): BatchPayload!
751+
deleteManyUsers(where: UserWhereInput): BatchPayload!
748752
deleteManyItems(where: ItemWhereInput): BatchPayload!
749753
deleteManyOrderItems(where: OrderItemWhereInput): BatchPayload!
750-
deleteManyOrders(where: OrderWhereInput): BatchPayload!
751754
}
752755

753756
enum MutationType {
@@ -1266,6 +1269,9 @@ input OrderItemWhereInput {
12661269
"""All values greater than or equal the given value."""
12671270
quantity_gte: Int
12681271
user: UserWhereInput
1272+
_MagicalBackRelation_OrderToOrderItem_every: OrderWhereInput
1273+
_MagicalBackRelation_OrderToOrderItem_some: OrderWhereInput
1274+
_MagicalBackRelation_OrderToOrderItem_none: OrderWhereInput
12691275
}
12701276

12711277
input OrderItemWhereUniqueInput {
@@ -1555,21 +1561,21 @@ enum Permission {
15551561
}
15561562

15571563
type Query {
1558-
users(where: UserWhereInput, orderBy: UserOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [User]!
15591564
cartItems(where: CartItemWhereInput, orderBy: CartItemOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [CartItem]!
1565+
orders(where: OrderWhereInput, orderBy: OrderOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Order]!
1566+
users(where: UserWhereInput, orderBy: UserOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [User]!
15601567
items(where: ItemWhereInput, orderBy: ItemOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Item]!
15611568
orderItems(where: OrderItemWhereInput, orderBy: OrderItemOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [OrderItem]!
1562-
orders(where: OrderWhereInput, orderBy: OrderOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [Order]!
1563-
user(where: UserWhereUniqueInput!): User
15641569
cartItem(where: CartItemWhereUniqueInput!): CartItem
1570+
order(where: OrderWhereUniqueInput!): Order
1571+
user(where: UserWhereUniqueInput!): User
15651572
item(where: ItemWhereUniqueInput!): Item
15661573
orderItem(where: OrderItemWhereUniqueInput!): OrderItem
1567-
order(where: OrderWhereUniqueInput!): Order
1568-
usersConnection(where: UserWhereInput, orderBy: UserOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): UserConnection!
15691574
cartItemsConnection(where: CartItemWhereInput, orderBy: CartItemOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): CartItemConnection!
1575+
ordersConnection(where: OrderWhereInput, orderBy: OrderOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): OrderConnection!
1576+
usersConnection(where: UserWhereInput, orderBy: UserOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): UserConnection!
15701577
itemsConnection(where: ItemWhereInput, orderBy: ItemOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): ItemConnection!
15711578
orderItemsConnection(where: OrderItemWhereInput, orderBy: OrderItemOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): OrderItemConnection!
1572-
ordersConnection(where: OrderWhereInput, orderBy: OrderOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): OrderConnection!
15731579

15741580
"""Fetches an object given its ID"""
15751581
node(
@@ -1579,11 +1585,11 @@ type Query {
15791585
}
15801586

15811587
type Subscription {
1582-
user(where: UserSubscriptionWhereInput): UserSubscriptionPayload
15831588
cartItem(where: CartItemSubscriptionWhereInput): CartItemSubscriptionPayload
1589+
order(where: OrderSubscriptionWhereInput): OrderSubscriptionPayload
1590+
user(where: UserSubscriptionWhereInput): UserSubscriptionPayload
15841591
item(where: ItemSubscriptionWhereInput): ItemSubscriptionPayload
15851592
orderItem(where: OrderItemSubscriptionWhereInput): OrderItemSubscriptionPayload
1586-
order(where: OrderSubscriptionWhereInput): OrderSubscriptionPayload
15871593
}
15881594

15891595
type User implements Node {
@@ -1597,7 +1603,7 @@ type User implements Node {
15971603
cart(where: CartItemWhereInput, orderBy: CartItemOrderByInput, skip: Int, after: String, before: String, first: Int, last: Int): [CartItem!]
15981604
createdAt: DateTime!
15991605
updatedAt: DateTime!
1600-
permissions: [Permission!]
1606+
permissions: [Permission!]!
16011607
}
16021608

16031609
"""A connection to a list of items."""
@@ -1697,7 +1703,7 @@ type UserPreviousValues {
16971703
resetTokenExpiry: String
16981704
createdAt: DateTime!
16991705
updatedAt: DateTime!
1700-
permissions: [Permission!]
1706+
permissions: [Permission!]!
17011707
}
17021708

17031709
type UserSubscriptionPayload {
@@ -1764,7 +1770,6 @@ input UserUpdateInput {
17641770
input UserUpdateOneInput {
17651771
create: UserCreateInput
17661772
connect: UserWhereUniqueInput
1767-
disconnect: Boolean
17681773
delete: Boolean
17691774
update: UserUpdateDataInput
17701775
upsert: UserUpsertNestedInput
@@ -2124,6 +2129,12 @@ input UserWhereInput {
21242129
cart_every: CartItemWhereInput
21252130
cart_some: CartItemWhereInput
21262131
cart_none: CartItemWhereInput
2132+
_MagicalBackRelation_OrderItemToUser_every: OrderItemWhereInput
2133+
_MagicalBackRelation_OrderItemToUser_some: OrderItemWhereInput
2134+
_MagicalBackRelation_OrderItemToUser_none: OrderItemWhereInput
2135+
_MagicalBackRelation_ItemToUser_every: ItemWhereInput
2136+
_MagicalBackRelation_ItemToUser_some: ItemWhereInput
2137+
_MagicalBackRelation_ItemToUser_none: ItemWhereInput
21272138
}
21282139

21292140
input UserWhereUniqueInput {

finished-application/frontend/components/Page.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Page extends React.Component {
5454
render() {
5555
return (
5656
<ThemeProvider theme={theme}>
57-
<StyledPage className="main">
57+
<StyledPage>
5858
<Meta />
5959
<Header />
6060
<Inner>{this.props.children}</Inner>
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import Nav from './Nav';
2+
3+
const Header = () => (
4+
<div>
5+
<div className="bar">
6+
<a href="">Sick Fits</a>
7+
<Nav />
8+
</div>
9+
<div className="sub-bar">
10+
<p>Search</p>
11+
</div>
12+
<div>Cart</div>
13+
</div>
14+
);
15+
16+
export default Header;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React, { Component } from 'react';
2+
import Header from '../components/Header';
3+
import Meta from '../components/Meta';
4+
5+
class Page extends Component {
6+
render() {
7+
return (
8+
<div>
9+
<Meta />
10+
<Header />
11+
{this.props.children}
12+
</div>
13+
);
14+
}
15+
}
16+
17+
export default Page;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Link from 'next/link';
2+
3+
const Nav = () => (
4+
<div>
5+
<Link href="/sell">
6+
<a>Sell!</a>
7+
</Link>
8+
<Link href="/">
9+
<a>Home!</a>
10+
</Link>
11+
</div>
12+
);
13+
14+
export default Nav;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React, { Component } from 'react';
2+
import Header from '../components/Header';
3+
import Meta from '../components/Meta';
4+
import styled, { ThemeProvider, injectGlobal } from 'styled-components';
5+
6+
const theme = {
7+
red: '#FF0000',
8+
black: '#393939',
9+
grey: '#3A3A3A',
10+
lightgrey: '#E1E1E1',
11+
offWhite: '#EDEDED',
12+
maxWidth: '1000px',
13+
bs: '0 12px 24px 0 rgba(0, 0, 0, 0.09)',
14+
};
15+
16+
const StyledPage = styled.div`
17+
background: white;
18+
color: ${props => props.theme.black};
19+
`;
20+
21+
const Inner = styled.div`
22+
max-width: ${props => props.theme.maxWidth};
23+
margin: 0 auto;
24+
padding: 2rem;
25+
`;
26+
27+
class Page extends Component {
28+
render() {
29+
return (
30+
<ThemeProvider theme={theme}>
31+
<StyledPage>
32+
<Meta />
33+
<Header />
34+
<Inner>{this.props.children}</Inner>
35+
</StyledPage>
36+
</ThemeProvider>
37+
);
38+
}
39+
}
40+
41+
export default Page;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import Nav from './Nav';
2+
import Link from 'next/link';
3+
import styled from 'styled-components';
4+
5+
const Logo = styled.h1`
6+
font-size: 4rem;
7+
margin-left: 2rem;
8+
position: relative;
9+
z-index: 2;
10+
transform: skew(-7deg);
11+
a {
12+
padding: 0.5rem 1rem;
13+
background: ${props => props.theme.red};
14+
color: white;
15+
text-transform: uppercase;
16+
text-decoration: none;
17+
}
18+
@media (max-width: 1300px) {
19+
margin: 0;
20+
text-align: center;
21+
}
22+
`;
23+
24+
const StyledHeader = styled.header`
25+
.bar {
26+
border-bottom: 10px solid ${props => props.theme.black};
27+
display: grid;
28+
grid-template-columns: auto 1fr;
29+
justify-content: space-between;
30+
align-items: stretch;
31+
@media (max-width: 1300px) {
32+
grid-template-columns: 1fr;
33+
justify-content: center;
34+
}
35+
}
36+
.sub-bar {
37+
display: grid;
38+
grid-template-columns: 1fr auto;
39+
border-bottom: 1px solid ${props => props.theme.lightgrey};
40+
}
41+
`;
42+
43+
const Header = () => (
44+
<StyledHeader>
45+
<div className="bar">
46+
<Logo>
47+
<Link href="/">
48+
<a>Sick Fits</a>
49+
</Link>
50+
</Logo>
51+
<Nav />
52+
</div>
53+
<div className="sub-bar">
54+
<p>Search</p>
55+
</div>
56+
<div>Cart</div>
57+
</StyledHeader>
58+
);
59+
60+
export default Header;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import Document, { Head, Main, NextScript } from 'next/document';
2+
import { ServerStyleSheet } from 'styled-components';
3+
4+
export default class MyDocument extends Document {
5+
static getInitialProps({ renderPage }) {
6+
const sheet = new ServerStyleSheet();
7+
const page = renderPage(App => props => sheet.collectStyles(<App {...props} />));
8+
const styleTags = sheet.getStyleElement();
9+
return { ...page, styleTags };
10+
}
11+
12+
render() {
13+
return (
14+
<html>
15+
<Head>{this.props.styleTags}</Head>
16+
<body>
17+
<Main />
18+
<NextScript />
19+
</body>
20+
</html>
21+
);
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
type User {
2+
id: ID! @unique
3+
name: String!
4+
email: String!
5+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
endpoint: ${env:PRISMA_ENDPOINT}
2+
datamodel: datamodel.graphql
3+
# secret: ${env:PRISMA_SECRET}
4+
hooks:
5+
post-deploy:
6+
- graphql get-schema -p prisma

0 commit comments

Comments
 (0)