Compare commits
2 Commits
3da160afc2
...
f7b665b2ec
Author | SHA1 | Date |
---|---|---|
gilex-dev | f7b665b2ec | |
gilex-dev | 60207beabd |
|
@ -1,4 +1,4 @@
|
|||
sqlite3_file: "YetAnotherToDoList.sqlite3"
|
||||
log_file: "YetAnotherToDoList.log"
|
||||
sqlite3_file: 'YetAnotherToDoList.sqlite3'
|
||||
log_file: 'YetAnotherToDoList.log'
|
||||
log_UTC: false
|
||||
port: 4242
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
root = true # false
|
||||
|
||||
[*]
|
||||
# overrides perettier's useTabs
|
||||
indent_style = tab # space
|
||||
|
||||
# overrides perettier's tabWidth
|
||||
# indent_size = 4 # whole number
|
||||
|
||||
# overrides perettier's tabWidth
|
||||
tab_width = 1 # whole number
|
||||
|
||||
end_of_line = lf # cr | crlf
|
||||
charset = utf-8 # latin1 | utf-8-bom | utf-16be | utf-16le
|
||||
|
||||
trim_trailing_whitespace = true # false
|
||||
|
||||
insert_final_newline = true # false
|
||||
|
||||
# overrides perettier's printWidth
|
||||
max_line_length = 80
|
|
@ -0,0 +1 @@
|
|||
* text=auto eol=lf
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"requirePragma": false,
|
||||
"insertPragma": false,
|
||||
"proseWrap": "always"
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"recommendations": [
|
||||
"golang.go",
|
||||
"graphql.vscode-graphql-syntax",
|
||||
"mtxr.sqltools",
|
||||
"mtxr.sqltools-driver-sqlite",
|
||||
"streetsidesoftware.code-spell-checker",
|
||||
"editorconfig.editorconfig"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"sqltools.useNodeRuntime": true,
|
||||
"sqltools.connections": [
|
||||
{
|
||||
"previewLimit": 50,
|
||||
"driver": "SQLite",
|
||||
"database": "${workspaceFolder:YetAnotherToDoList}/YetAnotherToDoList.sqlite3",
|
||||
"name": "development"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -5,10 +5,13 @@ Commands were run in the order listed below on a debian based system.
|
|||
## Initial setup
|
||||
|
||||
- Initialize go module
|
||||
|
||||
```bash
|
||||
go mod init somepi.ddns.net/gitea/gilex-dev/YetAnotherToDoList
|
||||
```
|
||||
- Install cobra-cli (try `~/go/bin/cobra-cli` if `cobra-cli` can not be found in your `PATH`)
|
||||
|
||||
- Install cobra-cli (try `~/go/bin/cobra-cli` if `cobra-cli` can not be found in
|
||||
your `PATH`)
|
||||
|
||||
```bash
|
||||
go install github.com/spf13/cobra-cli@latest
|
||||
|
@ -16,14 +19,19 @@ Commands were run in the order listed below on a debian based system.
|
|||
```
|
||||
|
||||
- Add missing modules
|
||||
|
||||
```bash
|
||||
go mod tidy
|
||||
```
|
||||
|
||||
- Add license command
|
||||
|
||||
```bash
|
||||
cobra-cli add license
|
||||
```
|
||||
|
||||
- Add qglgen
|
||||
|
||||
```bash
|
||||
printf '// +build tools\npackage tools\nimport (_ "github.com/99designs/gqlgen"\n _ "github.com/99designs/gqlgen/graphql/introspection")' | gofmt > tools.go
|
||||
go mod tidy
|
||||
|
@ -31,7 +39,9 @@ Commands were run in the order listed below on a debian based system.
|
|||
go mod tidy
|
||||
cobra-cli add server
|
||||
```
|
||||
|
||||
- Add go-sqlite3
|
||||
|
||||
```bash
|
||||
go get github.com/mattn/go-sqlite3
|
||||
CGO_ENABLED=1 go install github.com/mattn/go-sqlite3 # you may need to install gcc if not already present
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
---
|
||||
gitea: none
|
||||
include_toc: true
|
||||
---
|
||||
|
||||
# Contributing
|
||||
|
||||
This is a personal project to learn new languages and technics and thus does not
|
||||
really have a future you could contribute to. You are however welcome to fork
|
||||
and modify it while following the guidelines and licenses in
|
||||
[COPYING.md](./COPYING.md).
|
||||
|
||||
## Environment
|
||||
|
||||
Preferred editor: [VSCodium](https://vscodium.com/) with some
|
||||
[extensions](./.vscode/extensions.json).
|
||||
|
||||
For dependencies/tools, make sure to use the versions specified in
|
||||
[INSTALL.md#requirements](./INSTALL.md#requirements).
|
||||
|
||||
## Coding conventions/formatting
|
||||
|
||||
There is a [.editorconfig](./.editorconfig) file to use with compatible editors
|
||||
[1](https://editorconfig.org/#pre-installed), or with those who have plugins
|
||||
available [2](https://editorconfig.org/#download).
|
||||
|
||||
Please use [prettier](https://prettier.io/) and the supplied
|
||||
[configuration](./.prettierrc) to format the following file types:
|
||||
|
||||
- `.js`
|
||||
- `.vue`
|
||||
- `.css`
|
||||
- `.md`
|
||||
- `.yaml`
|
||||
- `.graphqls`, `.graphql`
|
||||
- `.json`
|
||||
|
||||
Use the following formatters with the following types:
|
||||
|
||||
- `.go` (use gofmt)
|
||||
|
||||
No formatter specified for the following types (adapt to existing style):
|
||||
|
||||
- `Makefile`
|
||||
- `.sql`
|
||||
- `.mod`, `.sum`
|
||||
|
||||
Do **not** change the formatting of license texts (e.g.
|
||||
[COPYING.md](./COPYING.md)).
|
||||
|
||||
### General
|
||||
|
||||
- We indent using `tabs` (4 spaces wide).
|
||||
- We use single-quotes `'` where possible.
|
||||
- We use `LF` line endings (enforced by [.gitattributes](./.gitattributes)).
|
||||
- We use `UTF-8` encoding where possible.
|
||||
- We end files with an empty line.
|
||||
- We use the string `TODO` to mark bits of code that need improvement.
|
||||
- We use the string `DEBUG` to mark bits of code that are only for debugging
|
||||
(remove before next commit).
|
||||
- We add (if possible) the following header to files that contain a reasonable
|
||||
amount of self-written code or are essential to the project:
|
||||
|
||||
```text
|
||||
/*
|
||||
YetAnotherToDoList
|
||||
Copyright © YYYY name your@email
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, version 3.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
```
|
||||
|
||||
### File specific rules
|
||||
|
||||
#### Markdown (.md)
|
||||
|
||||
- We add a single `h1` element per document (as a title of the document).
|
||||
- We use asterisks `*` for **bold** and _italic_, not underscores `_` .
|
||||
- We don't use citation blocks `>` for emphasis.
|
||||
- We end sentences with a full stop `.` .
|
||||
- We leave one space around backticks `` ` `` when used as inline code.
|
||||
- We add new lines around codeblocks ` ``` ` .
|
||||
- We indent using spaces (2 spaces wide).
|
||||
- We add a table of content (toc) in gitea's style where necessary:
|
||||
|
||||
```
|
||||
---
|
||||
gitea: none
|
||||
include_toc: true
|
||||
---
|
||||
```
|
||||
|
||||
#### YAML
|
||||
|
||||
We indent using spaces (1 space wide).
|
||||
|
||||
#### Bash (.sh)
|
||||
|
||||
We use `env` in the shebang: `#!/usr/bin/env bash`.
|
||||
|
||||
### File endings
|
||||
|
||||
#### .yaml and .yml
|
||||
|
||||
We use the `.yaml` file ending.
|
||||
|
||||
#### .graphql and .graphqls
|
||||
|
||||
- We use `.graphql` for writing client queries.
|
||||
|
||||
- We use `.graphqls` for defining our graph scheme.
|
||||
|
||||
## Commit messages
|
||||
|
||||
- We write in all lowercase except for special names, e.g. `update Makefile`
|
||||
- We write in imperative mood, e.g. `add contribution guidelines`, not
|
||||
`adding ... ` or `adds ... `.
|
13
README.md
13
README.md
|
@ -1,12 +1,19 @@
|
|||
# YetAnotherToDoList
|
||||
|
||||
A simple To Do List Web Application with Go backend, Vue.js frontend and a GraphQL API.
|
||||
A simple To Do List Web Application with Go backend, Vue.js frontend and a
|
||||
GraphQL API.
|
||||
|
||||
This is a simple project I created to learn the [Go](https://go.dev/) language, [GraphQL](https://graphql.org/) and [Vue.js](https://vuejs.org).
|
||||
This is a simple project I created to learn the [Go](https://go.dev/) language,
|
||||
[GraphQL](https://graphql.org/) and [Vue.js](https://vuejs.org).
|
||||
|
||||
Instructions on how to install can be found in [INSTALL.md](./INSTALL.md).
|
||||
|
||||
Once installed, you might want to run the queries in [example.graphql](./example.graphql).
|
||||
Once installed, you might want to run the queries in
|
||||
[example.graphql](./example.graphql).
|
||||
|
||||
## Contributing
|
||||
|
||||
For contributing see [CONTRIBUTING.md](./CONTRIBUTIN.md).
|
||||
|
||||
## License
|
||||
|
||||
|
|
104
example.graphql
104
example.graphql
|
@ -1,77 +1,77 @@
|
|||
# you first have to add a user to create todos
|
||||
|
||||
query getUser {
|
||||
user(id: 1) {
|
||||
id
|
||||
userName
|
||||
fullName
|
||||
todos {
|
||||
id
|
||||
text
|
||||
done
|
||||
}
|
||||
}
|
||||
user(id: 1) {
|
||||
id
|
||||
userName
|
||||
fullName
|
||||
todos {
|
||||
id
|
||||
text
|
||||
done
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query getTodo {
|
||||
todo(id: 1) {
|
||||
id
|
||||
text
|
||||
done
|
||||
}
|
||||
todo(id: 1) {
|
||||
id
|
||||
text
|
||||
done
|
||||
}
|
||||
}
|
||||
|
||||
query getTodos {
|
||||
todos {
|
||||
id
|
||||
text
|
||||
done
|
||||
user {
|
||||
id
|
||||
userName
|
||||
fullName
|
||||
todos {
|
||||
id # you could continue this
|
||||
}
|
||||
}
|
||||
}
|
||||
todos {
|
||||
id
|
||||
text
|
||||
done
|
||||
user {
|
||||
id
|
||||
userName
|
||||
fullName
|
||||
todos {
|
||||
id # you could continue this
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query getUsers {
|
||||
users {
|
||||
id
|
||||
userName
|
||||
fullName
|
||||
todos {
|
||||
id # ...and this too
|
||||
}
|
||||
}
|
||||
users {
|
||||
id
|
||||
userName
|
||||
fullName
|
||||
todos {
|
||||
id # ...and this too
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mutation createTodo {
|
||||
createTodo(input: { userId: 2, text: "adding a router and CSRF header" }) {
|
||||
id
|
||||
text
|
||||
done
|
||||
}
|
||||
createTodo(input: { userId: 2, text: "adding a router and CSRF header" }) {
|
||||
id
|
||||
text
|
||||
done
|
||||
}
|
||||
}
|
||||
|
||||
mutation updateTodo {
|
||||
updateTodo(id: 1, changes: { done: true }) {
|
||||
id
|
||||
text
|
||||
done
|
||||
}
|
||||
updateTodo(id: 1, changes: { done: true }) {
|
||||
id
|
||||
text
|
||||
done
|
||||
}
|
||||
}
|
||||
|
||||
mutation createUser {
|
||||
createUser(input: { userName: "1234Lorem", fullName: "Lorem I." }) {
|
||||
id
|
||||
}
|
||||
createUser(input: { userName: "1234Lorem", fullName: "Lorem I." }) {
|
||||
id
|
||||
}
|
||||
}
|
||||
|
||||
mutation updateUser {
|
||||
updateUser(id: "1", changes: { fullName: "Lorem Ipsum" }) {
|
||||
fullName
|
||||
}
|
||||
updateUser(id: "1", changes: { fullName: "Lorem Ipsum" }) {
|
||||
fullName
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
|
||||
# Where are all the schema files located? globs are supported eg src/**/*.graphqls
|
||||
schema:
|
||||
- graph/*.graphqls
|
||||
- graph/*.graphqls
|
||||
|
||||
# Where should the generated server code go?
|
||||
exec:
|
||||
filename: graph/generated.go
|
||||
package: graph
|
||||
filename: graph/generated.go
|
||||
package: graph
|
||||
|
||||
# Uncomment to enable federation
|
||||
# federation:
|
||||
|
@ -29,17 +29,17 @@ exec:
|
|||
|
||||
# Where should any generated models go?
|
||||
model:
|
||||
filename: graph/model/models_gen.go
|
||||
package: model
|
||||
filename: graph/model/models_gen.go
|
||||
package: model
|
||||
|
||||
# Where should the resolver implementations go?
|
||||
resolver:
|
||||
layout: follow-schema
|
||||
dir: graph
|
||||
package: graph
|
||||
filename_template: "{name}.resolvers.go"
|
||||
# Optional: turn on to not generate template comments above resolvers
|
||||
# omit_template_comment: false
|
||||
layout: follow-schema
|
||||
dir: graph
|
||||
package: graph
|
||||
filename_template: '{name}.resolvers.go'
|
||||
# Optional: turn on to not generate template comments above resolvers
|
||||
# omit_template_comment: false
|
||||
|
||||
# Optional: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models
|
||||
# struct_tag: json
|
||||
|
@ -81,7 +81,7 @@ resolver:
|
|||
# gqlgen will search for any type names in the schema in these go packages
|
||||
# if they match it will use them, otherwise it will generate them.
|
||||
autobind:
|
||||
- "somepi.ddns.net/gitea/gilex-dev/YetAnotherToDoList/graph/model"
|
||||
- 'somepi.ddns.net/gitea/gilex-dev/YetAnotherToDoList/graph/model'
|
||||
|
||||
# This section declares type mapping between the GraphQL and go type systems
|
||||
#
|
||||
|
@ -89,22 +89,22 @@ autobind:
|
|||
# modelgen, the others will be allowed when binding to fields. Configure them to
|
||||
# your liking
|
||||
models:
|
||||
ID:
|
||||
model:
|
||||
- github.com/99designs/gqlgen/graphql.ID
|
||||
- github.com/99designs/gqlgen/graphql.Int
|
||||
- github.com/99designs/gqlgen/graphql.Int64
|
||||
- github.com/99designs/gqlgen/graphql.Int32
|
||||
Int:
|
||||
model:
|
||||
- github.com/99designs/gqlgen/graphql.Int
|
||||
- github.com/99designs/gqlgen/graphql.Int64
|
||||
- github.com/99designs/gqlgen/graphql.Int32
|
||||
Todo:
|
||||
fields:
|
||||
user:
|
||||
resolver: true
|
||||
User:
|
||||
fields:
|
||||
todos:
|
||||
resolver: true
|
||||
ID:
|
||||
model:
|
||||
- github.com/99designs/gqlgen/graphql.ID
|
||||
- github.com/99designs/gqlgen/graphql.Int
|
||||
- github.com/99designs/gqlgen/graphql.Int64
|
||||
- github.com/99designs/gqlgen/graphql.Int32
|
||||
Int:
|
||||
model:
|
||||
- github.com/99designs/gqlgen/graphql.Int
|
||||
- github.com/99designs/gqlgen/graphql.Int64
|
||||
- github.com/99designs/gqlgen/graphql.Int32
|
||||
Todo:
|
||||
fields:
|
||||
user:
|
||||
resolver: true
|
||||
User:
|
||||
fields:
|
||||
todos:
|
||||
resolver: true
|
|
@ -18,51 +18,51 @@
|
|||
# https://gqlgen.com/getting-started/
|
||||
|
||||
type Todo {
|
||||
id: ID!
|
||||
text: String!
|
||||
done: Boolean!
|
||||
user: User!
|
||||
id: ID!
|
||||
text: String!
|
||||
done: Boolean!
|
||||
user: User!
|
||||
}
|
||||
|
||||
type User {
|
||||
id: ID!
|
||||
userName: String!
|
||||
fullName: String!
|
||||
todos: [Todo!]!
|
||||
id: ID!
|
||||
userName: String!
|
||||
fullName: String!
|
||||
todos: [Todo!]!
|
||||
}
|
||||
|
||||
type Query {
|
||||
todos: [Todo!]!
|
||||
users: [User!]!
|
||||
user(id: ID!): User!
|
||||
todo(id: ID!): Todo!
|
||||
todos: [Todo!]!
|
||||
users: [User!]!
|
||||
user(id: ID!): User!
|
||||
todo(id: ID!): Todo!
|
||||
}
|
||||
|
||||
input NewUser {
|
||||
userName: String!
|
||||
fullName: String!
|
||||
userName: String!
|
||||
fullName: String!
|
||||
}
|
||||
|
||||
input NewTodo {
|
||||
text: String!
|
||||
userId: ID!
|
||||
text: String!
|
||||
userId: ID!
|
||||
}
|
||||
|
||||
input updateTodo {
|
||||
text: String
|
||||
done: Boolean
|
||||
text: String
|
||||
done: Boolean
|
||||
}
|
||||
|
||||
input updateUser {
|
||||
userName: String
|
||||
fullName: String
|
||||
userName: String
|
||||
fullName: String
|
||||
}
|
||||
|
||||
type Mutation {
|
||||
createUser(input: NewUser!): User!
|
||||
createTodo(input: NewTodo!): Todo!
|
||||
updateTodo(id: ID!, changes: updateTodo!): Todo!
|
||||
updateUser(id: ID!, changes: updateUser!): User!
|
||||
deleteUser(id: ID!): ID
|
||||
deleteTodo(id: ID!): ID
|
||||
createUser(input: NewUser!): User!
|
||||
createTodo(input: NewTodo!): Todo!
|
||||
updateTodo(id: ID!, changes: updateTodo!): Todo!
|
||||
updateUser(id: ID!, changes: updateUser!): User!
|
||||
deleteUser(id: ID!): ID
|
||||
deleteTodo(id: ID!): ID
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue