~sircmpwn/paste.sr.ht

1331c0179ea10fd7d22d3d0df6bfdb1090f2a688 — Simon Ser 16 days ago 8000340 master
go generate
2 files changed, 91 insertions(+), 55 deletions(-)

M api/graph/api/generated.go
M api/graph/model/models_gen.go
M api/graph/api/generated.go => api/graph/api/generated.go +75 -50
@@ 434,22 434,28 @@ var sources = []*ast.Source{
scalar Cursor
scalar Time
scalar Upload
# URL from which some secondary data may be retrieved. You must provide the
# same Authentication header to this address as you did to the GraphQL resolver
# which provided it. The URL is not guaranteed to be consistent for an extended
# length of time; applications should submit a new GraphQL query each time they
# wish to access the data at the provided URL.
"""
URL from which some secondary data may be retrieved. You must provide the
same Authentication header to this address as you did to the GraphQL resolver
which provided it. The URL is not guaranteed to be consistent for an extended
length of time; applications should submit a new GraphQL query each time they
wish to access the data at the provided URL.
"""
scalar URL

# This is used to decorate fields which are only accessible with a personal
# access token, and are not available to clients using OAuth 2.0 access tokens.
"""
This is used to decorate fields which are only accessible with a personal
access token, and are not available to clients using OAuth 2.0 access tokens.
"""
directive @private on FIELD_DEFINITION

# This used to decorate fields which are for internal use, and are not
# available to normal API users.
"""
This used to decorate fields which are for internal use, and are not
available to normal API users.
"""
directive @internal on FIELD_DEFINITION

# Used to provide a human-friendly description of an access scope.
"Used to provide a human-friendly description of an access scope."
directive @scopehelp(details: String!) on ENUM_VALUE

enum AccessScope {


@@ 462,18 468,20 @@ enum AccessKind {
  RW @scopehelp(details: "read and write")
}

# Decorates fields for which access requires a particular OAuth 2.0 scope with
# 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.
"""
Decorates fields for which access requires a particular OAuth 2.0 scope with
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

enum Visibility {
  # Visible to everyone, listed on your profile
  "Visible to everyone, listed on your profile"
  PUBLIC
  # Visible to everyone (if they know the URL), not listed on your profile
  "Visible to everyone (if they know the URL), not listed on your profile"
  UNLISTED
  # Not visible to anyone except those explicitly added to the access list
  "Not visible to anyone except those explicitly added to the access list"
  PRIVATE
}



@@ 482,17 490,21 @@ type Version {
  major: Int!
  minor: Int!
  patch: Int!
  # If this API version is scheduled for deprecation, this is the date on which
  # it will stop working; or null if this API version is not scheduled for
  # deprecation.
  """
  If this API version is scheduled for deprecation, this is the date on which
  it will stop working; or null if this API version is not scheduled for
  deprecation.
  """
  deprecationDate: Time
}

interface Entity {
  id: Int!
  created: Time!
  # The canonical name of this entity. For users, this is their username
  # prefixed with '~'. Additional entity types will be supported in the future.
  """
  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!

  pastes(cursor: Cursor): PasteCursor! @access(scope: PASTES, kind: RO)


@@ 512,7 524,7 @@ type Paste {
  id: String!
  created: Time!
  visibility: Visibility!
  files: [File]!
  files: [File!]!

  user: Entity! @access(scope: PROFILE, kind: RO)
}


@@ 523,48 535,52 @@ type File {
  contents: URL!
}

# A cursor for enumerating pastes
#
# If there are additional results available, the cursor object may be passed
# back into the same endpoint to retrieve another page. If the cursor is null,
# there are no remaining results to return.
"""
A cursor for enumerating pastes

If there are additional results available, the cursor object may be passed
back into the same endpoint to retrieve another page. If the cursor is null,
there are no remaining results to return.
"""
type PasteCursor {
  results: [Paste!]!
  cursor: Cursor
}

type Query {
  # Returns API version information.
  "Returns API version information."
  version: Version!

  # Returns the authenticated user.
  "Returns the authenticated user."
  me: User! @access(scope: PROFILE, kind: RO)

  # Returns a specific user.
  "Returns a specific user."
  user(username: String!): User @access(scope: PROFILE, kind: RO)

  # Returns a list of pastes created by the authenticated user.
  "Returns a list of pastes created by the authenticated user."
  pastes(cursor: Cursor): PasteCursor @access(scope: PASTES, kind: RO)

  # Returns a paste by its ID.
  "Returns a paste by its ID."
  paste(id: String!): Paste @access(scope: PASTES, kind: RO)
}

type Mutation {
  # Creates a new paste from a list of files. The files uploaded must have a
  # content type of text/* and must be decodable as UTF-8.
  #
  # Note that the web UI will replace CRLF with LF in uploads; the GraphQL API
  # does not.
  """
  Creates a new paste from a list of files. The files uploaded must have a
  content type of text/* and must be decodable as UTF-8.

  Note that the web UI will replace CRLF with LF in uploads; the GraphQL API
  does not.
  """
  create(
    files: [Upload!]!,
    visibility: Visibility!,
  ): Paste! @access(scope: PASTES, kind: RW)

  # Updates the visibility of a paste.
  "Updates the visibility of a paste."
  update(id: String!, visibility: Visibility!): Paste @access(scope: PASTES, kind: RW)

  # Deletes a paste by its ID.
  "Deletes a paste by its ID."
  delete(id: String!): Paste @access(scope: PASTES, kind: RW)
}
`, BuiltIn: false},


@@ 1233,7 1249,7 @@ func (ec *executionContext) _Paste_files(ctx context.Context, field graphql.Coll
	}
	res := resTmp.([]*model.File)
	fc.Result = res
	return ec.marshalNFile2ᚕᚖgitᚗsrᚗhtᚋאsircmpwnᚋpasteᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐFile(ctx, field.Selections, res)
	return ec.marshalNFile2ᚕᚖgitᚗsrᚗhtᚋאsircmpwnᚋpasteᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐFileᚄ(ctx, field.Selections, res)
}

func (ec *executionContext) _Paste_user(ctx context.Context, field graphql.CollectedField, obj *model.Paste) (ret graphql.Marshaler) {


@@ 3891,7 3907,7 @@ func (ec *executionContext) marshalNEntity2gitᚗsrᚗhtᚋאsircmpwnᚋpasteᚗ
	return ec._Entity(ctx, sel, v)
}

func (ec *executionContext) marshalNFile2ᚕᚖgitᚗsrᚗhtᚋאsircmpwnᚋpasteᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐFile(ctx context.Context, sel ast.SelectionSet, v []*model.File) graphql.Marshaler {
func (ec *executionContext) marshalNFile2ᚕᚖgitᚗsrᚗhtᚋאsircmpwnᚋpasteᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐFileᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.File) graphql.Marshaler {
	ret := make(graphql.Array, len(v))
	var wg sync.WaitGroup
	isLen1 := len(v) == 1


@@ 3915,7 3931,7 @@ func (ec *executionContext) marshalNFile2ᚕᚖgitᚗsrᚗhtᚋאsircmpwnᚋpast
			if !isLen1 {
				defer wg.Done()
			}
			ret[i] = ec.marshalOFile2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋpasteᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐFile(ctx, sel, v[i])
			ret[i] = ec.marshalNFile2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋpasteᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐFile(ctx, sel, v[i])
		}
		if isLen1 {
			f(i)


@@ 3926,9 3942,25 @@ func (ec *executionContext) marshalNFile2ᚕᚖgitᚗsrᚗhtᚋאsircmpwnᚋpast
	}
	wg.Wait()

	for _, e := range ret {
		if e == graphql.Null {
			return graphql.Null
		}
	}

	return ret
}

func (ec *executionContext) marshalNFile2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋpasteᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐFile(ctx context.Context, sel ast.SelectionSet, v *model.File) graphql.Marshaler {
	if v == nil {
		if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
			ec.Errorf(ctx, "must not be null")
		}
		return graphql.Null
	}
	return ec._File(ctx, sel, v)
}

func (ec *executionContext) unmarshalNInt2int(ctx context.Context, v interface{}) (int, error) {
	res, err := graphql.UnmarshalInt(v)
	return res, graphql.ErrorOnPath(ctx, err)


@@ 4464,13 4496,6 @@ func (ec *executionContext) marshalOCursor2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋcore
	return v
}

func (ec *executionContext) marshalOFile2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋpasteᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐFile(ctx context.Context, sel ast.SelectionSet, v *model.File) graphql.Marshaler {
	if v == nil {
		return graphql.Null
	}
	return ec._File(ctx, sel, v)
}

func (ec *executionContext) marshalOPaste2ᚖgitᚗsrᚗhtᚋאsircmpwnᚋpasteᚗsrᚗhtᚋapiᚋgraphᚋmodelᚐPaste(ctx context.Context, sel ast.SelectionSet, v *model.Paste) graphql.Marshaler {
	if v == nil {
		return graphql.Null

M api/graph/model/models_gen.go => api/graph/model/models_gen.go +16 -5
@@ 15,15 15,23 @@ type Entity interface {
	IsEntity()
}

// A cursor for enumerating pastes
//
// If there are additional results available, the cursor object may be passed
// back into the same endpoint to retrieve another page. If the cursor is null,
// there are no remaining results to return.
type PasteCursor struct {
	Results []*Paste      `json:"results"`
	Cursor  *model.Cursor `json:"cursor"`
}

type Version struct {
	Major           int        `json:"major"`
	Minor           int        `json:"minor"`
	Patch           int        `json:"patch"`
	Major int `json:"major"`
	Minor int `json:"minor"`
	Patch int `json:"patch"`
	// If this API version is scheduled for deprecation, this is the date on which
	// it will stop working; or null if this API version is not scheduled for
	// deprecation.
	DeprecationDate *time.Time `json:"deprecationDate"`
}



@@ 112,9 120,12 @@ func (e AccessScope) MarshalGQL(w io.Writer) {
type Visibility string

const (
	VisibilityPublic   Visibility = "PUBLIC"
	// Visible to everyone, listed on your profile
	VisibilityPublic Visibility = "PUBLIC"
	// Visible to everyone (if they know the URL), not listed on your profile
	VisibilityUnlisted Visibility = "UNLISTED"
	VisibilityPrivate  Visibility = "PRIVATE"
	// Not visible to anyone except those explicitly added to the access list
	VisibilityPrivate Visibility = "PRIVATE"
)

var AllVisibility = []Visibility{