ソースを参照

Type bugfixes;

bjorn 9 年 前
コミット
1a1d5b67e8
1 ファイル変更14 行追加3 行削除
  1. 14 3
      types.lua

+ 14 - 3
types.lua

@@ -46,7 +46,7 @@ function types.object(config)
     fields[fieldName] = {
       name = fieldName,
       kind = field.kind,
-      args = field.args or {}
+      arguments = field.arguments or {}
     }
   end
 
@@ -54,7 +54,8 @@ function types.object(config)
     __type = 'Object',
     name = config.name,
     isTypeOf = config.isTypeOf,
-    fields = fields
+    fields = fields,
+    interfaces = config.interfaces
   }
 
   instance.nonNull = types.nonNull(instance)
@@ -69,11 +70,21 @@ function types.interface(config)
     assert(type(config.resolveType) == 'function', 'must provide resolveType as a function')
   end
 
+  local fields = {}
+  for fieldName, field in pairs(config.fields) do
+    field = field.__type and { kind = field } or field
+    fields[fieldName] = {
+      name = fieldName,
+      kind = field.kind,
+      arguments = field.arguments or {}
+    }
+  end
+
   local instance = {
     __type = 'Interface',
     name = config.name,
     description = config.description,
-    fields = config.fields,
+    fields = fields,
     resolveType = config.resolveType
   }