Browse Source

Auth: Removed session/auth system from GraphQL API

1.0
Gisle Aune 6 years ago
parent
commit
9d7fd498a9
  1. 26
      graphql/resolver/mutations/login.go
  2. 16
      graphql/resolver/mutations/logout.go
  3. 13
      graphql/resolver/queries/session.go
  4. 11
      graphql/schema/root.graphql
  5. 5
      graphql/schema/types/session.graphql

26
graphql/resolver/mutations/login.go

@ -1,26 +0,0 @@
package mutations
import (
"context"
"git.aiterp.net/rpdata/api/graphql/resolver/types"
"git.aiterp.net/rpdata/api/internal/session"
)
// LoginArgs is args for the login mutation
type LoginArgs struct {
Username string
Password string
}
// Login resolves the login mutation
func (r *MutationResolver) Login(ctx context.Context, args *LoginArgs) (*types.SessionResolver, error) {
session := session.FromContext(ctx)
err := session.Login(args.Username, args.Password)
if err != nil {
return nil, err
}
return &types.SessionResolver{S: session}, nil
}

16
graphql/resolver/mutations/logout.go

@ -1,16 +0,0 @@
package mutations
import (
"context"
"git.aiterp.net/rpdata/api/graphql/resolver/types"
"git.aiterp.net/rpdata/api/internal/session"
)
// Logout resolves mutation.logout
func (r *MutationResolver) Logout(ctx context.Context) (*types.SessionResolver, error) {
session := session.FromContext(ctx)
session.Logout()
return &types.SessionResolver{S: session}, nil
}

13
graphql/resolver/queries/session.go

@ -1,13 +0,0 @@
package queries
import (
"context"
"git.aiterp.net/rpdata/api/graphql/resolver/types"
"git.aiterp.net/rpdata/api/internal/session"
)
// Session resolves query.session
func (r *QueryResolver) Session(ctx context.Context) (*types.SessionResolver, error) {
return &types.SessionResolver{S: session.FromContext(ctx)}, nil
}

11
graphql/schema/root.graphql

@ -49,10 +49,6 @@ type Query {
# Find all distinct tags used in stories # Find all distinct tags used in stories
tags: [Tag!]! tags: [Tag!]!
# Find current session
session: Session!
} }
# The Mutation type represents write entry points into the API. # The Mutation type represents write entry points into the API.
@ -137,13 +133,6 @@ type Mutation {
# Remove a chapter # Remove a chapter
removeChapter(id: String!): Chapter! removeChapter(id: String!): Chapter!
# Log in
login(username: String!, password: String!): Session!
# Log out
logout(): Session!
} }
schema { schema {

5
graphql/schema/types/session.graphql

@ -1,5 +0,0 @@
# The session represents the current login state
type Session {
# The user that is logged in, null if not logged in
user: User
}
Loading…
Cancel
Save