Revert "api/graph: Enable GraphQL federation"
This reverts commit ae02f6feca
.
This commit is contained in:
parent
89407c354d
commit
085a966e08
|
@ -15,5 +15,4 @@ overrides/
|
||||||
.pgp
|
.pgp
|
||||||
api/api
|
api/api
|
||||||
api/graph/api/generated.go
|
api/graph/api/generated.go
|
||||||
api/graph/api/federation.go
|
|
||||||
*_gen.go
|
*_gen.go
|
||||||
|
|
|
@ -8,9 +8,9 @@ exec:
|
||||||
package: api
|
package: api
|
||||||
|
|
||||||
# Uncomment to enable federation
|
# Uncomment to enable federation
|
||||||
federation:
|
# federation:
|
||||||
filename: graph/api/federation.go
|
# filename: graph/generated/federation.go
|
||||||
package: api
|
# package: generated
|
||||||
|
|
||||||
# Where should any generated models go?
|
# Where should any generated models go?
|
||||||
model:
|
model:
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
package graph
|
|
||||||
|
|
||||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
|
||||||
// will be copied through when generating and any unknown code will be moved to the end.
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
|
|
||||||
"git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/api"
|
|
||||||
"git.sr.ht/~sircmpwn/meta.sr.ht/api/graph/model"
|
|
||||||
"git.sr.ht/~sircmpwn/meta.sr.ht/api/loaders"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (r *entityResolver) FindOAuthClientByUUID(ctx context.Context, uuid string) (*model.OAuthClient, error) {
|
|
||||||
return loaders.ForContext(ctx).OAuthClientsByUUID.Load(uuid)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *entityResolver) FindUserByID(ctx context.Context, id int) (*model.User, error) {
|
|
||||||
return loaders.ForContext(ctx).UsersByID.Load(id)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Entity returns api.EntityResolver implementation.
|
|
||||||
func (r *Resolver) Entity() api.EntityResolver { return &entityResolver{r} }
|
|
||||||
|
|
||||||
type entityResolver struct{ *Resolver }
|
|
|
@ -23,8 +23,6 @@ type OAuthClient struct {
|
||||||
fields *database.ModelFields
|
fields *database.ModelFields
|
||||||
}
|
}
|
||||||
|
|
||||||
func (OAuthClient) IsEntity() {}
|
|
||||||
|
|
||||||
func (oc *OAuthClient) As(alias string) *OAuthClient {
|
func (oc *OAuthClient) As(alias string) *OAuthClient {
|
||||||
oc.alias = alias
|
oc.alias = alias
|
||||||
return oc
|
return oc
|
||||||
|
|
|
@ -11,36 +11,36 @@ access token, and are not available to clients using OAuth 2.0 access tokens.
|
||||||
directive @private on FIELD_DEFINITION
|
directive @private on FIELD_DEFINITION
|
||||||
|
|
||||||
"""
|
"""
|
||||||
This is used to decorate fields which are for internal use, and are not
|
This used to decorate fields which are for internal use, and are not
|
||||||
available to normal API users.
|
available to normal API users.
|
||||||
"""
|
"""
|
||||||
directive @internal on FIELD_DEFINITION
|
directive @internal on FIELD_DEFINITION
|
||||||
|
|
||||||
directive @anoninternal on FIELD_DEFINITION
|
directive @anoninternal on FIELD_DEFINITION
|
||||||
|
|
||||||
|
"""
|
||||||
|
Used to provide a human-friendly description of an access scope.
|
||||||
|
"""
|
||||||
|
directive @scopehelp(details: String!) on ENUM_VALUE
|
||||||
|
|
||||||
enum AccessScope {
|
enum AccessScope {
|
||||||
"Audit log"
|
AUDIT_LOG @scopehelp(details: "audit log")
|
||||||
AUDIT_LOG
|
BILLING @scopehelp(details: "billing history")
|
||||||
"Billing history"
|
PGP_KEYS @scopehelp(details: "PGP keys")
|
||||||
BILLING
|
SSH_KEYS @scopehelp(details: "SSH keys")
|
||||||
"PGP keys"
|
PROFILE @scopehelp(details: "profile information")
|
||||||
PGP_KEYS
|
|
||||||
"SSH keys"
|
|
||||||
SSH_KEYS
|
|
||||||
"Profile information"
|
|
||||||
PROFILE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum AccessKind {
|
enum AccessKind {
|
||||||
"Read-only"
|
RO @scopehelp(details: "read")
|
||||||
RO
|
RW @scopehelp(details: "read and write")
|
||||||
"Read and write"
|
|
||||||
RW
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Decorates fields for which access requires a particular OAuth 2.0 scope with
|
Decorates fields for which access requires a particular OAuth 2.0 scope with
|
||||||
read or write access.
|
read or write access. For the meta.sr.ht API, you have access to all public
|
||||||
|
information without any special permissions - user profile information,
|
||||||
|
public keys, and so on.
|
||||||
"""
|
"""
|
||||||
directive @access(scope: AccessScope!, kind: AccessKind!) on FIELD_DEFINITION | ENUM_VALUE
|
directive @access(scope: AccessScope!, kind: AccessKind!) on FIELD_DEFINITION | ENUM_VALUE
|
||||||
|
|
||||||
|
@ -57,6 +57,17 @@ type Version {
|
||||||
deprecationDate: Time
|
deprecationDate: Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface Entity {
|
||||||
|
id: Int!
|
||||||
|
created: Time!
|
||||||
|
updated: Time!
|
||||||
|
"""
|
||||||
|
The canonical name of this entity. For users, this is their username
|
||||||
|
prefixed with '~'. Additional entity types will be supported in the future.
|
||||||
|
"""
|
||||||
|
canonicalName: String!
|
||||||
|
}
|
||||||
|
|
||||||
enum UserType {
|
enum UserType {
|
||||||
UNCONFIRMED
|
UNCONFIRMED
|
||||||
ACTIVE_NON_PAYING
|
ACTIVE_NON_PAYING
|
||||||
|
@ -67,7 +78,7 @@ enum UserType {
|
||||||
SUSPENDED
|
SUSPENDED
|
||||||
}
|
}
|
||||||
|
|
||||||
type User @key(fields: "id") {
|
type User implements Entity {
|
||||||
id: Int!
|
id: Int!
|
||||||
created: Time!
|
created: Time!
|
||||||
updated: Time!
|
updated: Time!
|
||||||
|
@ -133,7 +144,7 @@ type OAuthGrantRegistration {
|
||||||
secret: String!
|
secret: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
type OAuthClient @key(fields: "uuid") {
|
type OAuthClient {
|
||||||
id: Int!
|
id: Int!
|
||||||
uuid: String!
|
uuid: String!
|
||||||
redirectUrl: String!
|
redirectUrl: String!
|
||||||
|
@ -142,7 +153,7 @@ type OAuthClient @key(fields: "uuid") {
|
||||||
description: String
|
description: String
|
||||||
url: String
|
url: String
|
||||||
|
|
||||||
owner: User! @access(scope: PROFILE, kind: RO)
|
owner: Entity! @access(scope: PROFILE, kind: RO)
|
||||||
}
|
}
|
||||||
|
|
||||||
type OAuthClientRegistration {
|
type OAuthClientRegistration {
|
||||||
|
@ -320,7 +331,7 @@ type WebhookSubscriptionCursor {
|
||||||
cursor: Cursor
|
cursor: Cursor
|
||||||
}
|
}
|
||||||
|
|
||||||
extend type Query {
|
type Query {
|
||||||
"Returns API version information."
|
"Returns API version information."
|
||||||
version: Version!
|
version: Version!
|
||||||
|
|
||||||
|
@ -417,7 +428,7 @@ input ProfileWebhookInput {
|
||||||
query: String!
|
query: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
extend type Mutation {
|
type Mutation {
|
||||||
updateUser(input: UserInput): User! @access(scope: PROFILE, kind: RW)
|
updateUser(input: UserInput): User! @access(scope: PROFILE, kind: RW)
|
||||||
|
|
||||||
createPGPKey(key: String!): PGPKey! @access(scope: PGP_KEYS, kind: RW)
|
createPGPKey(key: String!): PGPKey! @access(scope: PGP_KEYS, kind: RW)
|
||||||
|
@ -442,7 +453,7 @@ extend type Mutation {
|
||||||
may be used to access details of the event which trigged the webhook. The
|
may be used to access details of the event which trigged the webhook. The
|
||||||
query may not make any mutations.
|
query may not make any mutations.
|
||||||
"""
|
"""
|
||||||
createProfileWebhook(config: ProfileWebhookInput!): WebhookSubscription!
|
createWebhook(config: ProfileWebhookInput!): WebhookSubscription!
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Deletes a user profile webhook. Any events already queued may still be
|
Deletes a user profile webhook. Any events already queued may still be
|
||||||
|
@ -452,7 +463,7 @@ extend type Mutation {
|
||||||
Manually deleting a webhook configured by a third-party client may cause
|
Manually deleting a webhook configured by a third-party client may cause
|
||||||
unexpected behavior with the third-party integration.
|
unexpected behavior with the third-party integration.
|
||||||
"""
|
"""
|
||||||
deleteProfileWebhook(id: Int!): WebhookSubscription
|
deleteWebhook(id: Int!): WebhookSubscription
|
||||||
|
|
||||||
### ###
|
### ###
|
||||||
### The following resolvers are for internal use. ###
|
### The following resolvers are for internal use. ###
|
||||||
|
|
|
@ -486,7 +486,7 @@ func (r *mutationResolver) UpdateSSHKey(ctx context.Context, id int) (*model.SSH
|
||||||
return &key, nil
|
return &key, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *mutationResolver) CreateProfileWebhook(ctx context.Context, config model.ProfileWebhookInput) (model.WebhookSubscription, error) {
|
func (r *mutationResolver) CreateWebhook(ctx context.Context, config model.ProfileWebhookInput) (model.WebhookSubscription, error) {
|
||||||
schema := server.ForContext(ctx).Schema
|
schema := server.ForContext(ctx).Schema
|
||||||
if err := corewebhooks.Validate(schema, config.Query); err != nil {
|
if err := corewebhooks.Validate(schema, config.Query); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -563,7 +563,7 @@ func (r *mutationResolver) CreateProfileWebhook(ctx context.Context, config mode
|
||||||
return &sub, nil
|
return &sub, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *mutationResolver) DeleteProfileWebhook(ctx context.Context, id int) (model.WebhookSubscription, error) {
|
func (r *mutationResolver) DeleteWebhook(ctx context.Context, id int) (model.WebhookSubscription, error) {
|
||||||
var sub model.ProfileWebhookSubscription
|
var sub model.ProfileWebhookSubscription
|
||||||
|
|
||||||
filter, err := corewebhooks.FilterWebhooks(ctx)
|
filter, err := corewebhooks.FilterWebhooks(ctx)
|
||||||
|
@ -1167,7 +1167,7 @@ func (r *mutationResolver) SendEmailNotification(ctx context.Context, subject st
|
||||||
return err == nil, err
|
return err == nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *oAuthClientResolver) Owner(ctx context.Context, obj *model.OAuthClient) (*model.User, error) {
|
func (r *oAuthClientResolver) Owner(ctx context.Context, obj *model.OAuthClient) (model.Entity, error) {
|
||||||
return loaders.ForContext(ctx).UsersByID.Load(obj.OwnerID)
|
return loaders.ForContext(ctx).UsersByID.Load(obj.OwnerID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue