Skip to content

Commit

Permalink
Add user roles
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrekmonko committed Oct 14, 2023
1 parent c3d7c9d commit cb07a95
Show file tree
Hide file tree
Showing 10 changed files with 629 additions and 257 deletions.
9 changes: 2 additions & 7 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,8 @@ var cfgFile string
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "portfello",
Short: "A brief description of your application",
Long: `A longer description that spans multiple lines and likely contains
examples and usage of using your application. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Short: "Backend services for PortfelloApp",
Long: `PortfelloApp is an opensource project for managing your household budget.`,
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
Expand Down
2 changes: 1 addition & 1 deletion dbschema/migrations/0001_initial.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ create table users
constraint users_pk
primary key,
display_name text not null,
is_active bool default false not null,
email text not null,
created_at timestamp default now() not null
);

31 changes: 17 additions & 14 deletions graph/schema.graphqls
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
# GraphQL schema example
#
# https://gqlgen.com/getting-started/

type Todo {
id: ID!
text: String!
done: Boolean!
user: User!
type Role {
userId: String!
role: RoleId!
}

type User {
id: ID!
email: String!
displayName: String!
}

type Query {
todos: [Todo!]!
roles: [Role!]!
users: [User!]!
}

input NewTodo {
text: String!
userId: String!
enum RoleId {
user
admin
super
}

input NewUser {
email: String!
displayName: String!
}

type Mutation {
createTodo(input: NewTodo!): Todo!
userCreate(input: NewUser!): User!
userAssignRoles(input: [String!]): [Role!]
userGetRoles(userId: String!): [RoleId!]
}
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ 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.
*/
//go:generate sqlc generate
//go:generate go run github.com/99designs/gqlgen generate
package main

import "github.com/piotrekmonko/portfello/cmd"
Expand Down
2 changes: 1 addition & 1 deletion pkg/dao/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/dao/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cb07a95

Please sign in to comment.