Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): Bump @babel/traverse from 7.22.17 to 7.24.7 in /example #3

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SALEOR_API_URL=
18 changes: 18 additions & 0 deletions example/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://json.schemastore.org/eslintrc.json",
"plugins": ["@typescript-eslint"],
"parserOptions": {
"project": "tsconfig.json"
},
"root": true,
"extends": ["plugin:@typescript-eslint/recommended", "next/core-web-vitals", "prettier"],
"overrides": [
{
"files": ["src/app/**/{page,layout,loading,route}.ts?(x)"],
"rules": {
"import/no-default-export": "off"
}
}
],
"ignorePatterns": ["*.js", "*.jsx"]
}
39 changes: 39 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files
.env

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts

# graphql
generated/
27 changes: 27 additions & 0 deletions example/.graphqlrc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { CodegenConfig } from "@graphql-codegen/cli";
import { loadEnvConfig } from "@next/env";

loadEnvConfig(".");

const config: CodegenConfig = {
overwrite: true,
schema: process.env.SALEOR_API_URL,
documents: "graphql/**/*.graphql",
generates: {
"generated/": {
preset: "client",
config: {
useTypeImports: true,
skipTypename: true,
enumsAsTypes: true,
defaultScalarType: "unknown",
documentMode: "string",
},
presetConfig: {
fragmentMasking: false,
},
},
},
};

export default config;
1 change: 1 addition & 0 deletions example/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
3 changes: 3 additions & 0 deletions example/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pnpm-lock.yaml
.next/
generated
6 changes: 6 additions & 0 deletions example/.stackblitzrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"startCommand": "pnpm generate && pnpm dev",
"env": {
"SALEOR_API_URL": "https://zaiste.saleor.cloud/graphql/"
}
}
79 changes: 79 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
![Next.js App Router + Saleor](https://user-images.githubusercontent.com/44495184/210545042-0537d49f-6ab8-4e52-af75-225370789c2b.png)

<img width="1383" alt="Saleor Example: Next.js 13 App Router Starter" src="https://github.com/saleor/example-nextjs-app-router-starter/assets/200613/2de5b286-a05c-4eee-9591-b4b01c3c7ee7">

<div align="center">
<h1>Next.js (App Router) Starter</h1>
</div>

<div align="center">
<p>A minimalistic boilerplate to start developing Next.js applications with <a href="https://github.com/saleor/saleor">Saleor</a>.</p>
</div>

<div align="center">
<a href="https://stackblitz.com/github/saleor/example-nextjs-app-router-starter">
<img
alt="Open in StackBlitz"
src="https://developer.stackblitz.com/img/open_in_stackblitz.svg"
target="_blank"
/>
</a>
</div>

<br/>

<div align="center">
<a href="https://saleor.io/">🏠 Website</a>
<span> • </span>
<a href="https://docs.saleor.io/docs/3.x/">📚 Docs</a>
<span> • </span>
<a href="https://saleor.io/blog/">📰 Blog</a>
<span> • </span>
<a href="https://twitter.com/getsaleor">🐦 Twitter</a>
<span> • </span>
<a href="https://discord.gg/H52JTZAtSH">💬 Discord</a>
</div>

## Motivation

🤏 **Bare bones**: Useful for prototyping or building your stack from scratch.

💪 **Typesafe**: Get productive with code generation and types.

## Stack:

- [Next.js App Router](https://nextjs.org/) with static data fetching
- [GraphQL Code Generator](https://the-guild.dev/graphql/codegen)
- [TypeScript](https://www.typescriptlang.org/)
- [pnpm](https://pnpm.io/)

## Quickstart

1. Create a new repository from this template ("Use this template")
2. Create `.env` file based on `.env.example`:

```bash
cp .env.example .env
```

3. Replace the `SALEOR_API_URL` environment variable with the address of your Saleor instance.

4. Install the dependencies:

```bash
pnpm i
```

5. Generate the types based on GraphQL schema:

```bash
pnpm generate
```

6. Start the development server:

```bash
pnpm dev
```

7. Enjoy! 🎉
17 changes: 17 additions & 0 deletions example/graphql/CheckoutComplete.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
mutation CheckoutComplete($checkoutId: ID!) {
checkoutComplete(id: $checkoutId) {
order {
id
errors {
field
message
code
}
}
errors {
field
message
code
}
}
}
44 changes: 44 additions & 0 deletions example/graphql/CreateCheckout.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
mutation CreateCheckout($variantId: ID!) {
checkoutCreate(
input: {
channel: "default-channel"
lines: [{ quantity: 1, variantId: $variantId }]
languageCode: EN_US
email: "[email protected]"
billingAddress: {
firstName: "John"
lastName: "Doe"
streetAddress1: "813 Howard Street"
city: "Oswego"
countryArea: "NY"
postalCode: "13126"
country: US
}
shippingAddress: {
firstName: "John"
lastName: "Doe"
streetAddress1: "813 Howard Street"
city: "Oswego"
countryArea: "NY"
postalCode: "13126"
country: US
}
}
) {
checkout {
id
availablePaymentGateways {
id
name
}
shippingMethods {
id
name
price {
currency
amount
}
}
}
}
}
17 changes: 17 additions & 0 deletions example/graphql/CurrentUser.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
query CurrentUser {
me {
id
lastLogin
dateJoined
email
firstName
lastName
avatar {
url
alt
}
orders {
totalCount
}
}
}
17 changes: 17 additions & 0 deletions example/graphql/GetCheckoutById.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
query GetCheckoutById($id: ID!) {
checkout(id: $id) {
id
lines {
id
variant {
product {
name
}
}
}
availablePaymentGateways {
id
name
}
}
}
36 changes: 36 additions & 0 deletions example/graphql/GetOrderById.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
query GetOrderById($orderId: ID!) {
order(id: $orderId) {
id
number
statusDisplay
lines {
id
productName
quantity
quantityFulfilled
thumbnail(size: 256) {
url
}
unitPrice {
gross {
amount
currency
}
}
}
total {
tax {
amount
currency
}
gross {
amount
currency
}
}
totalCharged {
amount
currency
}
}
}
13 changes: 13 additions & 0 deletions example/graphql/GetTransactionById.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
query GetTransactionById($transactionId: ID!) {
transaction(id: $transactionId) {
id
events {
id
type
amount {
amount
currency
}
}
}
}
18 changes: 18 additions & 0 deletions example/graphql/PaymentGatewayInitialize.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
mutation PaymentGatewayInitialize($checkoutId: ID!, $data: JSON, $appId: String!) {
paymentGatewayInitialize(paymentGateways: [{ id: $appId, data: $data }], id: $checkoutId) {
gatewayConfigs {
id
data
errors {
field
message
code
}
}
errors {
field
message
code
}
}
}
34 changes: 34 additions & 0 deletions example/graphql/ProductList.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
query ProductList {
products(
first: 1
channel: "default-channel"
where: { isAvailable: true, giftCard: false }
sortBy: { field: PRICE, direction: DESC }
) {
edges {
node {
id
name
thumbnail(size: 2048) {
url
alt
}
category {
name
}
defaultVariant {
id
name
pricing {
price {
gross {
amount
currency
}
}
}
}
}
}
}
}
Loading
Loading