小编use*_*943的帖子

graphql-go:使用Object作为查询的输入参数

我试图将一个对象作为参数传递给查询(而不是标量).从文档看来,这应该是可能的,但我无法弄清楚如何使它工作.

我正在使用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)

go graphql

10
推荐指数
1
解决办法
2826
查看次数

NSUserDefaults setObject:forKey:尝试插入非属性列表对象

我觉得我在这里做的事情显然是错的,但我无法理解!我正在尝试将包含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)

dictionary objective-c nsuserdefaults ios

0
推荐指数
1
解决办法
8973
查看次数

标签 统计

dictionary ×1

go ×1

graphql ×1

ios ×1

nsuserdefaults ×1

objective-c ×1