-
Notifications
You must be signed in to change notification settings - Fork 150
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
♻️ ⏪ Revert changes for old queries #3579
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using Bencodex; | ||
using GraphQL.Language.AST; | ||
using GraphQL.Types; | ||
using Libplanet.Common; | ||
|
||
namespace Libplanet.Explorer.GraphTypes | ||
{ | ||
public class LegacyBencodexValueType : StringGraphType | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does we haven't more good naming...? I guess if you have plan about more refactoring, maybe you need LegacyBencodexValueV2Type later. 🙄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, it's just more work then. To be more sensible and be managable, we need an entirely new set of "V2" scheme which doesn't share the root. Then we'd have to create an entirely new copies of query related codes, management of V1 and V2 graph types, etc. 🙄 |
||
{ | ||
private static readonly Codec _codec = new(); | ||
|
||
public LegacyBencodexValueType() | ||
{ | ||
Name = "LegacyBencodexValue"; | ||
} | ||
|
||
public override object? Serialize(object? value) | ||
{ | ||
if (value is Bencodex.Types.IValue iv) | ||
{ | ||
return _codec.Encode(iv); | ||
} | ||
|
||
return value; | ||
} | ||
|
||
public override object? ParseValue(object? value) | ||
{ | ||
return value switch | ||
{ | ||
null => null, | ||
string hex => _codec.Decode(ByteUtil.ParseHex(hex)), | ||
_ => throw new ArgumentException( | ||
$"Expected a hexadecimal string but {value}", | ||
nameof(value) | ||
), | ||
}; | ||
} | ||
|
||
public override object? ParseLiteral(IValue? value) | ||
{ | ||
if (value is StringValue) | ||
{ | ||
return ParseValue(value.Value); | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add issue or PR numbers about previous feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How? I guess we can refer to #3560 maybe, but I don't think it'd help much. Also the whole point of this PR is to not fix the issue since we don't want to deal with the consequences of breaking the API. 😑