Skip to content

Commit

Permalink
Merge pull request #814 from redwoodjs/pp-integrate-decoupled
Browse files Browse the repository at this point in the history
Integrate decoupled
  • Loading branch information
peterp committed Jul 9, 2020
2 parents 2a20afc + 9a9651e commit 6b8eaed
Show file tree
Hide file tree
Showing 157 changed files with 30,795 additions and 1,453 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dist
fixtures
packages/api/importAll.macro.js
packages/core/src/__tests__/__fixtures__/**/*
packages/core/config/storybook/**/*
13 changes: 13 additions & 0 deletions __fixtures__/example-todo-main-with-errors/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
node_modules
dist
yarn-error.log
.docz
.env
.DS_Store
.wip

api/prisma/dev.sqlite
packages/photon/runtime
packages/photon/index.js
packages/photon/index.d.ts

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"editor.tabSize": 2,
"files.trimTrailingWhitespace": true,
"eslint.format.enable": true,

"editor.codeActionsOnSave": {
"source.fixAll": true,
},
}
21 changes: 21 additions & 0 deletions __fixtures__/example-todo-main-with-errors/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Redwood

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
37 changes: 37 additions & 0 deletions __fixtures__/example-todo-main-with-errors/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Todo

This is an example Redwood app, implementing a very minimal todo application.
Features you can see in action here:

- Redwood Cells (see TodoListCell.js).
- Optimistic GraphQL response with Apollo (see AddTodo.js).
- SVG loader (see Check.js)
- StyledComponents usage (and stylistic approach)

## Getting Started

### Setup

We use Yarn as our package manager. To get the dependencies installed, just do
this in the root directory:

```terminal
yarn
```

Set up the database and generate the database client:

```terminal
yarn redwood db up
```

### Fire it up

```terminal
yarn redwood dev
```

Browse to `http://localhost:8910` (or run `yarn redwood open`) to see the web app.

Lambda functions run on
`localhost:8911` but are proxied via `localhost:8910/api/functions/*`.
1 change: 1 addition & 0 deletions __fixtures__/example-todo-main-with-errors/api/.babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: "../babel.config.js" }
9 changes: 9 additions & 0 deletions __fixtures__/example-todo-main-with-errors/api/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"src/*": ["./src/*"]
}
},
"include": ["generated/**/*", "src/**/*"]
}
8 changes: 8 additions & 0 deletions __fixtures__/example-todo-main-with-errors/api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"private": true,
"name": "api",
"version": "0.0.0",
"dependencies": {
"@redwoodjs/api": "0.7.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Migration `20200415083240`

This migration has been generated by Peter Pistorius at 4/15/2020, 8:32:40 AM.
You can check out the [state of the schema](./schema.prisma) after the migration.

## Database Steps

```sql
CREATE TABLE "quaint"."Todo" (
"body" TEXT NOT NULL ,
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
"status" TEXT NOT NULL DEFAULT 'off'
)

CREATE UNIQUE INDEX "quaint"."Todo.body" ON "Todo"("body")
```

## Changes

```diff
diff --git schema.prisma schema.prisma
migration ..20200415083240
--- datamodel.dml
+++ datamodel.dml
@@ -1,0 +1,17 @@
+datasource sqlite {
+ url = "file:./dev.sqlite"
+ provider = "sqlite"
+}
+
+generator photonjs {
+ provider = "prisma-client-js"
+}
+
+// Define your own models here and run `yarn rw db save` to create
+// migrations for them.
+
+model Todo {
+ id Int @id @default(autoincrement())
+ body String @unique
+ status String @default("off")
+}
```


Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
datasource sqlite {
url = "***"
provider = "sqlite"
}

generator photonjs {
provider = "prisma-client-js"
}

// Define your own models here and run `yarn rw db save` to create
// migrations for them.

model Todo {
id Int @id @default(autoincrement())
body String @unique
status String @default("off")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"version": "0.3.14-fixed",
"steps": [
{
"tag": "CreateSource",
"source": "sqlite"
},
{
"tag": "CreateArgument",
"location": {
"tag": "Source",
"source": "sqlite"
},
"argument": "url",
"value": "\"file:./dev.sqlite\""
},
{
"tag": "CreateArgument",
"location": {
"tag": "Source",
"source": "sqlite"
},
"argument": "provider",
"value": "\"sqlite\""
},
{
"tag": "CreateModel",
"model": "Todo"
},
{
"tag": "CreateField",
"model": "Todo",
"field": "id",
"type": "Int",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Todo",
"field": "id"
},
"directive": "id"
}
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Todo",
"field": "id"
},
"directive": "default"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Todo",
"field": "id"
},
"directive": "default"
},
"argument": "",
"value": "autoincrement()"
},
{
"tag": "CreateField",
"model": "Todo",
"field": "body",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Todo",
"field": "body"
},
"directive": "unique"
}
},
{
"tag": "CreateField",
"model": "Todo",
"field": "status",
"type": "String",
"arity": "Required"
},
{
"tag": "CreateDirective",
"location": {
"path": {
"tag": "Field",
"model": "Todo",
"field": "status"
},
"directive": "default"
}
},
{
"tag": "CreateArgument",
"location": {
"tag": "Directive",
"path": {
"tag": "Field",
"model": "Todo",
"field": "status"
},
"directive": "default"
},
"argument": "",
"value": "\"off\""
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# IF THERE'S A GIT CONFLICT IN THIS FILE, DON'T SOLVE IT MANUALLY!
# INSTEAD EXECUTE `prisma migrate fix`
# Prisma Migrate lockfile v1
# Read more about conflict resolution here: TODO

20200415083240
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
datasource sqlite {
url = "file:./dev.sqlite"
provider = "sqlite"
}

generator photonjs {
provider = "prisma-client-js"
}

// Define your own models here and run `yarn rw db save` to create
// migrations for them.

model Todo {
id Int @id @default(autoincrement())
body String @unique
status String @default("off")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {
createGraphQLHandler,
makeMergedSchema,
makeServices,
} from '@redwoodjs/api'
import importAll from '@redwoodjs/api/importAll.macro'

import { db } from 'src/lib/db'

const schemas = importAll('api', 'graphql')
const services = importAll('api', 'services')

export const handler = createGraphQLHandler(
{
schema: makeMergedSchema({
schemas,
services: makeServices({ services }),
}),
},
db
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const schema = gql`
type Todo {
id: Int!
body: String!
status: String!
}
type Query {
todos: [Todo]
}
type Mutation {
createTodo(body: String!): Todo
updateTodoStatus(id: Int!, status: String!): Todo
renameTodo(id: Int!, body: String!): Todo
}
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { db } from 'src/lib/db'

export const todos = () => db.todo.findMany()

export const createTodo = ({ body }) => db.todo.create({ data: { body } })

export const updateTodoStatus = ({ id, status }) =>
db.todo.update({
data: { status },
where: { id },
})

export const renameTodo = ({ id, body }) =>
db.todo.update({
data: { body },
where: { id },
})
3 changes: 3 additions & 0 deletions __fixtures__/example-todo-main-with-errors/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ['@redwoodjs/core/config/babel-preset'],
}
Loading

0 comments on commit 6b8eaed

Please sign in to comment.