apply formatting guidelines to existing files

This commit is contained in:
gilex-dev 2023-10-20 13:59:19 +02:00
parent 60207beabd
commit f7b665b2ec
6 changed files with 129 additions and 116 deletions

View File

@ -1,4 +1,4 @@
sqlite3_file: "YetAnotherToDoList.sqlite3" sqlite3_file: 'YetAnotherToDoList.sqlite3'
log_file: "YetAnotherToDoList.log" log_file: 'YetAnotherToDoList.log'
log_UTC: false log_UTC: false
port: 4242 port: 4242

View File

@ -5,10 +5,13 @@ Commands were run in the order listed below on a debian based system.
## Initial setup ## Initial setup
- Initialize go module - Initialize go module
```bash ```bash
go mod init somepi.ddns.net/gitea/gilex-dev/YetAnotherToDoList 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 ```bash
go install github.com/spf13/cobra-cli@latest 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 - Add missing modules
```bash ```bash
go mod tidy go mod tidy
``` ```
- Add license command - Add license command
```bash ```bash
cobra-cli add license cobra-cli add license
``` ```
- Add qglgen - Add qglgen
```bash ```bash
printf '// +build tools\npackage tools\nimport (_ "github.com/99designs/gqlgen"\n _ "github.com/99designs/gqlgen/graphql/introspection")' | gofmt > tools.go printf '// +build tools\npackage tools\nimport (_ "github.com/99designs/gqlgen"\n _ "github.com/99designs/gqlgen/graphql/introspection")' | gofmt > tools.go
go mod tidy go mod tidy
@ -31,9 +39,11 @@ Commands were run in the order listed below on a debian based system.
go mod tidy go mod tidy
cobra-cli add server cobra-cli add server
``` ```
- Add go-sqlite3 - Add go-sqlite3
```bash ```bash
go get github.com/mattn/go-sqlite3 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 CGO_ENABLED=1 go install github.com/mattn/go-sqlite3 # you may need to install gcc if not already present
go mod tidy go mod tidy
``` ```

View File

@ -1,12 +1,15 @@
# YetAnotherToDoList # 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). 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 ## Contributing

View File

@ -1,77 +1,77 @@
# you first have to add a user to create todos # you first have to add a user to create todos
query getUser { query getUser {
user(id: 1) { user(id: 1) {
id id
userName userName
fullName fullName
todos { todos {
id id
text text
done done
} }
} }
} }
query getTodo { query getTodo {
todo(id: 1) { todo(id: 1) {
id id
text text
done done
} }
} }
query getTodos { query getTodos {
todos { todos {
id id
text text
done done
user { user {
id id
userName userName
fullName fullName
todos { todos {
id # you could continue this id # you could continue this
} }
} }
} }
} }
query getUsers { query getUsers {
users { users {
id id
userName userName
fullName fullName
todos { todos {
id # ...and this too id # ...and this too
} }
} }
} }
mutation createTodo { mutation createTodo {
createTodo(input: { userId: 2, text: "adding a router and CSRF header" }) { createTodo(input: { userId: 2, text: "adding a router and CSRF header" }) {
id id
text text
done done
} }
} }
mutation updateTodo { mutation updateTodo {
updateTodo(id: 1, changes: { done: true }) { updateTodo(id: 1, changes: { done: true }) {
id id
text text
done done
} }
} }
mutation createUser { mutation createUser {
createUser(input: { userName: "1234Lorem", fullName: "Lorem I." }) { createUser(input: { userName: "1234Lorem", fullName: "Lorem I." }) {
id id
} }
} }
mutation updateUser { mutation updateUser {
updateUser(id: "1", changes: { fullName: "Lorem Ipsum" }) { updateUser(id: "1", changes: { fullName: "Lorem Ipsum" }) {
fullName fullName
} }
} }

View File

@ -15,12 +15,12 @@
# Where are all the schema files located? globs are supported eg src/**/*.graphqls # Where are all the schema files located? globs are supported eg src/**/*.graphqls
schema: schema:
- graph/*.graphqls - graph/*.graphqls
# Where should the generated server code go? # Where should the generated server code go?
exec: exec:
filename: graph/generated.go filename: graph/generated.go
package: graph package: graph
# Uncomment to enable federation # Uncomment to enable federation
# federation: # federation:
@ -29,17 +29,17 @@ exec:
# Where should any generated models go? # Where should any generated models go?
model: model:
filename: graph/model/models_gen.go filename: graph/model/models_gen.go
package: model package: model
# Where should the resolver implementations go? # Where should the resolver implementations go?
resolver: resolver:
layout: follow-schema layout: follow-schema
dir: graph dir: graph
package: graph package: graph
filename_template: "{name}.resolvers.go" filename_template: '{name}.resolvers.go'
# Optional: turn on to not generate template comments above resolvers # Optional: turn on to not generate template comments above resolvers
# omit_template_comment: false # omit_template_comment: false
# Optional: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models # Optional: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models
# struct_tag: json # struct_tag: json
@ -81,7 +81,7 @@ resolver:
# gqlgen will search for any type names in the schema in these go packages # 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. # if they match it will use them, otherwise it will generate them.
autobind: 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 # 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 # modelgen, the others will be allowed when binding to fields. Configure them to
# your liking # your liking
models: models:
ID: ID:
model: model:
- github.com/99designs/gqlgen/graphql.ID - github.com/99designs/gqlgen/graphql.ID
- github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32 - github.com/99designs/gqlgen/graphql.Int32
Int: Int:
model: model:
- github.com/99designs/gqlgen/graphql.Int - github.com/99designs/gqlgen/graphql.Int
- github.com/99designs/gqlgen/graphql.Int64 - github.com/99designs/gqlgen/graphql.Int64
- github.com/99designs/gqlgen/graphql.Int32 - github.com/99designs/gqlgen/graphql.Int32
Todo: Todo:
fields: fields:
user: user:
resolver: true resolver: true
User: User:
fields: fields:
todos: todos:
resolver: true resolver: true

View File

@ -18,51 +18,51 @@
# https://gqlgen.com/getting-started/ # https://gqlgen.com/getting-started/
type Todo { type Todo {
id: ID! id: ID!
text: String! text: String!
done: Boolean! done: Boolean!
user: User! user: User!
} }
type User { type User {
id: ID! id: ID!
userName: String! userName: String!
fullName: String! fullName: String!
todos: [Todo!]! todos: [Todo!]!
} }
type Query { type Query {
todos: [Todo!]! todos: [Todo!]!
users: [User!]! users: [User!]!
user(id: ID!): User! user(id: ID!): User!
todo(id: ID!): Todo! todo(id: ID!): Todo!
} }
input NewUser { input NewUser {
userName: String! userName: String!
fullName: String! fullName: String!
} }
input NewTodo { input NewTodo {
text: String! text: String!
userId: ID! userId: ID!
} }
input updateTodo { input updateTodo {
text: String text: String
done: Boolean done: Boolean
} }
input updateUser { input updateUser {
userName: String userName: String
fullName: String fullName: String
} }
type Mutation { type Mutation {
createUser(input: NewUser!): User! createUser(input: NewUser!): User!
createTodo(input: NewTodo!): Todo! createTodo(input: NewTodo!): Todo!
updateTodo(id: ID!, changes: updateTodo!): Todo! updateTodo(id: ID!, changes: updateTodo!): Todo!
updateUser(id: ID!, changes: updateUser!): User! updateUser(id: ID!, changes: updateUser!): User!
deleteUser(id: ID!): ID deleteUser(id: ID!): ID
deleteTodo(id: ID!): ID deleteTodo(id: ID!): ID
} }