Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added: serialize in asScalar #144

Merged
merged 4 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@
"repositoryURL": "https://github.com/GraphQLSwift/Graphiti.git",
"state": {
"branch": null,
"revision": "f80bd1342e52b9ee9e19f7f017dc4545e6c3cb6d",
"version": "1.10.1"
"revision": "ed06f0608a72176fd572763660e7492bfb53a419",
"version": "1.15.1"
}
},
{
"package": "GraphQL",
"repositoryURL": "https://github.com/GraphQLSwift/GraphQL.git",
"state": {
"branch": null,
"revision": "1b9d48ce0f0ad8280f75ce9914579aaac5881bc6",
"version": "2.5.1"
"revision": "ec809df8cce95d6aea820f70f04067abc08080f2",
"version": "2.10.3"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let package = Package(
// Dependencies declare other packages that this package depends on.
// .package(url: /* package url */, from: "1.0.0"),
.package(url: "https://github.com/GraphQLSwift/GraphQL.git", from: "2.4.5"),
.package(url: "https://github.com/GraphQLSwift/Graphiti.git", from: "1.2.2"),
.package(url: "https://github.com/GraphQLSwift/Graphiti.git", from: "1.15.1"),
.package(url: "https://github.com/vapor/vapor.git", from: "4.77.0"),
],
targets: [
Expand Down
1 change: 1 addition & 0 deletions Sources/Pioneer/Extensions/Int/UInt64+Nanoseconds.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//
// Created by d-exclaimation on 14:19.
//
import Vapor

public extension Optional where WrappedType == UInt64 {
/// Convert the given value in seconds into nanoseconds
Expand Down
16 changes: 14 additions & 2 deletions Sources/Pioneer/GraphQL/BuiltinTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,20 @@ public struct ID: Codable, ExpressibleByStringLiteral, CustomStringConvertible,

/// Apply scalar to Graphiti schema to allow the use of ID.
public static func asScalar<Resolver, Context>() -> Scalar<Resolver, Context, Self> {
.init(ID.self, as: "ID")
.description("The ID scalar type represents a unique identifier, often used to refetch an object or as the key for a cache. The ID type is serialized in the same way as a String; however, defining it as an ID signifies that it is not intended to be human‐readable")
.init(
ID.self,
as: "ID",
serialize: { value, _ in
try GraphQLID.serialize(value: value)
},
parseValue: { inputValue, _ in
try GraphQLID.parseValue(value: inputValue)
},
parseLiteral: { ast, _ in
try GraphQLID.parseLiteral(valueAST: ast)
}
)
.description("The ID scalar type represents a unique identifier, often used to refetch an object or as the key for a cache. The ID type is serialized in the same way as a String; however, defining it as an ID signifies that it is not intended to be human‐readable")
}

/// Create a new ID from UUID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import class GraphQL.GraphQLJSONEncoder
import Vapor

extension GraphQLJSONEncoder: ContentEncoder {
extension GraphQLJSONEncoder: Vapor.ContentEncoder {
public func encode<E>(_ encodable: E, to body: inout NIOCore.ByteBuffer, headers: inout NIOHTTP1.HTTPHeaders) throws where E: Encodable {
headers.contentType = .json
try body.writeBytes(self.encode(encodable))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
import struct GraphQL.GraphQLResult
import protocol Vapor.Content

extension GraphQLResult: Content {}
extension GraphQLResult: Vapor.Content {}
2 changes: 1 addition & 1 deletion Sources/Pioneer/Vapor/Http/Pioneer+IDE.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extension Pioneer {
case .sandbox:
return serve(html: embeddedSandboxHtml)
case let .redirect(to: cloud):
return req.redirect(to: cloud.url, type: .permanent)
return req.redirect(to: cloud.url, redirectType: .permanent)
case .disable:
return Response(status: .notFound)
}
Expand Down
Loading