我试图将一个对象作为参数传递给查询(而不是标量).从文档看来,这应该是可能的,但我无法弄清楚如何使它工作.
我正在使用graphql-go,这是测试模式:
var fileDocumentType = graphql.NewObject(graphql.ObjectConfig{
Name: "FileDocument",
Fields: graphql.Fields{
"id": &graphql.Field{
Type: graphql.String,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
if fileDoc, ok := p.Source.(data_format.FileDocument); ok {
return fileDoc.Id, nil
}
return "", nil
},
},
"tags": &graphql.Field{
Type: graphql.NewList(tagsDataType),
Args: graphql.FieldConfigArgument{
"tags": &graphql.ArgumentConfig{
Type: tagsInputType,
},
},
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
fmt.Println(p.Source)
fmt.Println(p.Args)
if fileDoc, ok := p.Source.(data_format.FileDocument); ok {
return fileDoc.Tags, nil
}
return nil, nil
},
},
},
})
Run Code Online (Sandbox Code Playgroud)
我试图使用的输入类型(我已尝试过InputObject和标准对象)
var tagsInputType = graphql.NewInputObject(graphql.InputObjectConfig{
Name: …Run Code Online (Sandbox Code Playgroud) 我觉得我在这里做的事情显然是错的,但我无法理解!我正在尝试将包含NSStrings和NSNumbers以及NSBooleans的NSMutableDictionary保存到iOS 7.1上的NSUserDefaults中.
这是字典定义:
- (NSMutableDictionary *)hotLevelsDict
{
if ( (!_hotLevelsDict) || ([_hotLevelsDict count] < 1) )
{
_hotLevelsDict = [NSMutableDictionary dictionaryWithDictionary:
@{@100: [NSMutableDictionary dictionaryWithDictionary:@{@"time": @20, @"points": @50, @"complete": @NO}],
@200: [NSMutableDictionary dictionaryWithDictionary:@{@"time": @20, @"points": @100, @"complete": @NO}],
@500: [NSMutableDictionary dictionaryWithDictionary:@{@"time": @20, @"points": @200, @"complete": @NO}],
@1000: [NSMutableDictionary dictionaryWithDictionary:@{@"time": @20, @"points": @200, @"complete": @NO}],
@2000: [NSMutableDictionary dictionaryWithDictionary:@{@"time": @20, @"points": @500, @"complete": @NO}],
@5000: [NSMutableDictionary dictionaryWithDictionary:@{@"time": @20, @"points": @1000, @"complete": @NO}],
@10000: [NSMutableDictionary dictionaryWithDictionary:@{@"time": @20, @"points": @1000, @"complete": @NO}],
@20000: [NSMutableDictionary dictionaryWithDictionary:@{@"time": …Run Code Online (Sandbox Code Playgroud)