generated from okp4/template-go
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
222 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package scalar | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
|
||
"github.com/99designs/gqlgen/graphql" | ||
"github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
func UnmarshalAccAddress(v interface{}) (types.AccAddress, error) { | ||
strAddress, ok := v.(string) | ||
if !ok { | ||
return nil, fmt.Errorf("expect type 'string' and got type '%T'", v) | ||
} | ||
|
||
return types.AccAddressFromBech32(strAddress) | ||
} | ||
|
||
func MarshalAccAddress(addr types.AccAddress) graphql.Marshaler { | ||
return graphql.WriterFunc(func(w io.Writer) { | ||
_, _ = w.Write(addr) | ||
}) | ||
} | ||
|
||
func UnmarshalValoperAddress(v interface{}) (types.ValAddress, error) { | ||
strAddress, ok := v.(string) | ||
if !ok { | ||
return nil, fmt.Errorf("expect type 'string' and got type '%T'", v) | ||
} | ||
|
||
return types.ValAddressFromBech32(strAddress) | ||
} | ||
|
||
func MarshalValoperAddress(addr types.ValAddress) graphql.Marshaler { | ||
return graphql.WriterFunc(func(w io.Writer) { | ||
_, _ = w.Write(addr) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package scalar | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
|
||
"github.com/99designs/gqlgen/graphql" | ||
"go.mongodb.org/mongo-driver/bson/primitive" | ||
) | ||
|
||
func UnmarshalCursor(v interface{}) (primitive.ObjectID, error) { | ||
strCursor, ok := v.(string) | ||
if !ok { | ||
return primitive.ObjectID{}, fmt.Errorf("expect type 'string' and got type '%T'", v) | ||
} | ||
|
||
return primitive.ObjectIDFromHex(strCursor) | ||
} | ||
|
||
func MarshalCursor(c primitive.ObjectID) graphql.Marshaler { | ||
return graphql.WriterFunc(func(w io.Writer) { | ||
_, _ = w.Write([]byte(c.Hex())) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package scalar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package scalar | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"io" | ||
"net/url" | ||
|
||
"github.com/99designs/gqlgen/graphql" | ||
) | ||
|
||
func UnmarshalURI(v interface{}) (*url.URL, error) { | ||
strURL, ok := v.(string) | ||
if !ok { | ||
return nil, fmt.Errorf("expect type 'string' and got type '%T'", v) | ||
} | ||
|
||
return url.Parse(strURL) | ||
} | ||
|
||
func MarshalURI(uri *url.URL) graphql.Marshaler { | ||
return graphql.WriterFunc(func(w io.Writer) { | ||
var buffer bytes.Buffer | ||
|
||
buffer.WriteRune('"') | ||
buffer.WriteString(uri.String()) | ||
buffer.WriteRune('"') | ||
|
||
_, _ = buffer.WriteTo(w) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters