debug DefaultValue
This commit is contained in:
		@@ -361,6 +361,17 @@ func NewSchema(config Config) (graphql.Schema, error) {
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	work := graphql.NewObject(graphql.ObjectConfig{
 | 
			
		||||
		Name:        "Work",
 | 
			
		||||
		Description: "作品",
 | 
			
		||||
		Fields: graphql.Fields{
 | 
			
		||||
			"id":          &graphql.Field{Type: graphql.Int, Description: "作品ID"},
 | 
			
		||||
			"title":       &graphql.Field{Type: graphql.String, Description: "作品标题"},
 | 
			
		||||
			"create_time": &graphql.Field{Type: graphql.DateTime, Description: "作品创建时间"},
 | 
			
		||||
			"update_time": &graphql.Field{Type: graphql.DateTime, Description: "作品更新时间"},
 | 
			
		||||
		},
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	image.AddFieldConfig("user", &graphql.Field{Type: user, Description: "图像所属用户"})
 | 
			
		||||
	image.AddFieldConfig("similars", &graphql.Field{Type: graphql.NewList(image), Description: "相似的图像", Resolve: func(p graphql.ResolveParams) (interface{}, error) {
 | 
			
		||||
		return []Image{}, nil
 | 
			
		||||
@@ -538,7 +549,7 @@ func NewSchema(config Config) (graphql.Schema, error) {
 | 
			
		||||
				"rank":        &graphql.ArgumentConfig{Type: graphql.String, Description: "筛选游戏中含有指定排名的"},
 | 
			
		||||
				"create_time": &graphql.ArgumentConfig{Type: graphql.DateTime, Description: "按创建时间筛选游戏"},
 | 
			
		||||
				"update_time": &graphql.ArgumentConfig{Type: graphql.DateTime, Description: "按修改时间筛选游戏"},
 | 
			
		||||
				"sort":        &graphql.ArgumentConfig{Type: graphql.String, Description: "按指定字段排序游戏"},
 | 
			
		||||
				"sort":        &graphql.ArgumentConfig{Type: graphql.String, Description: "按指定字段排序游戏", DefaultValue: "id"},
 | 
			
		||||
				"order":       &graphql.ArgumentConfig{Type: orderType, Description: "排序类型(升序或降序)", DefaultValue: "ASC"},
 | 
			
		||||
				"first":       &graphql.ArgumentConfig{Type: graphql.Int, Description: "翻页参数(傳回清單中的前n個元素)"},
 | 
			
		||||
				"last":        &graphql.ArgumentConfig{Type: graphql.Int, Description: "翻页参数(傳回清單中的最後n個元素)"},
 | 
			
		||||
@@ -619,7 +630,7 @@ func NewSchema(config Config) (graphql.Schema, error) {
 | 
			
		||||
				Name:        "WorkConnection",
 | 
			
		||||
				Description: "条件筛选作品列表",
 | 
			
		||||
				Fields: graphql.Fields{
 | 
			
		||||
					"list": &graphql.Field{Type: graphql.NewList(article), Description: "作品列表"},
 | 
			
		||||
					"list": &graphql.Field{Type: graphql.NewList(work), Description: "作品列表"},
 | 
			
		||||
					//"total": &graphql.Field{Type: graphql.Int, Description: "作品总数"},
 | 
			
		||||
				},
 | 
			
		||||
			}),
 | 
			
		||||
@@ -629,6 +640,12 @@ func NewSchema(config Config) (graphql.Schema, error) {
 | 
			
		||||
				"tags":        &graphql.ArgumentConfig{Type: graphql.String, Description: "筛选作品中含有指定标签的"},
 | 
			
		||||
				"create_time": &graphql.ArgumentConfig{Type: graphql.DateTime, Description: "筛选作品中创建时间等于指定值的"},
 | 
			
		||||
				"update_time": &graphql.ArgumentConfig{Type: graphql.DateTime, Description: "筛选作品中更新时间等于指定值的"},
 | 
			
		||||
				"sort":        &graphql.ArgumentConfig{Type: graphql.String, Description: "按指定字段排序游戏", DefaultValue: "id"},
 | 
			
		||||
				"order":       &graphql.ArgumentConfig{Type: orderType, Description: "排序类型(升序或降序)", DefaultValue: "ASC"},
 | 
			
		||||
				"first":       &graphql.ArgumentConfig{Type: graphql.Int, Description: "翻页参数(傳回清單中的前n個元素)"},
 | 
			
		||||
				"last":        &graphql.ArgumentConfig{Type: graphql.Int, Description: "翻页参数(傳回清單中的最後n個元素)"},
 | 
			
		||||
				"after":       &graphql.ArgumentConfig{Type: graphql.String, Description: "翻页参数(傳回清單中指定遊標之後的元素)"},
 | 
			
		||||
				"before":      &graphql.ArgumentConfig{Type: graphql.String, Description: "翻页参数(傳回清單中指定遊標之前的元素)"},
 | 
			
		||||
			},
 | 
			
		||||
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
 | 
			
		||||
				var works []Work
 | 
			
		||||
@@ -638,7 +655,7 @@ func NewSchema(config Config) (graphql.Schema, error) {
 | 
			
		||||
				var query = goqu.Dialect("mysql").From("web_article")
 | 
			
		||||
 | 
			
		||||
				// 筛选条件
 | 
			
		||||
				for _, format := range []string{"id", "style", "device", "orientation", "era", "category_id", "tags"} {
 | 
			
		||||
				for _, format := range []string{"id", "tags"} {
 | 
			
		||||
					if p.Args[format] != nil {
 | 
			
		||||
						query = query.Where(goqu.C(format).Eq(p.Args[format]))
 | 
			
		||||
					}
 | 
			
		||||
@@ -688,6 +705,7 @@ func NewSchema(config Config) (graphql.Schema, error) {
 | 
			
		||||
				`, sql, cursor, limit)
 | 
			
		||||
 | 
			
		||||
				if err := db.Limit(limit).Where("category_top_id = 1").Find(&works).Error; err != nil {
 | 
			
		||||
					log.Println("获取作品列表失败", err)
 | 
			
		||||
					return nil, err
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
@@ -714,6 +732,12 @@ func NewSchema(config Config) (graphql.Schema, error) {
 | 
			
		||||
				"tags":        &graphql.ArgumentConfig{Type: graphql.String, Description: "筛选文章中含有指定标签的"},
 | 
			
		||||
				"create_time": &graphql.ArgumentConfig{Type: graphql.DateTime, Description: "筛选文章中创建时间等于指定值的"},
 | 
			
		||||
				"update_time": &graphql.ArgumentConfig{Type: graphql.DateTime, Description: "筛选文章中更新时间等于指定值的"},
 | 
			
		||||
				"sort":        &graphql.ArgumentConfig{Type: graphql.String, Description: "按指定字段排序游戏", DefaultValue: "id"},
 | 
			
		||||
				"order":       &graphql.ArgumentConfig{Type: orderType, Description: "排序类型(升序或降序)", DefaultValue: "ASC"},
 | 
			
		||||
				"first":       &graphql.ArgumentConfig{Type: graphql.Int, Description: "翻页参数(傳回清單中的前n個元素)"},
 | 
			
		||||
				"last":        &graphql.ArgumentConfig{Type: graphql.Int, Description: "翻页参数(傳回清單中的最後n個元素)"},
 | 
			
		||||
				"after":       &graphql.ArgumentConfig{Type: graphql.String, Description: "翻页参数(傳回清單中指定遊標之後的元素)"},
 | 
			
		||||
				"before":      &graphql.ArgumentConfig{Type: graphql.String, Description: "翻页参数(傳回清單中指定遊標之前的元素)"},
 | 
			
		||||
			},
 | 
			
		||||
			Resolve: func(p graphql.ResolveParams) (interface{}, error) {
 | 
			
		||||
				var articles []Article
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user