Browse Source

Add simple subscription type to satisfy clients that use a newer spec

Zeeshan Lakhani 8 years ago
parent
commit
119aafe825
2 changed files with 14 additions and 1 deletions
  1. 9 1
      graphql/introspection.lua
  2. 5 0
      graphql/schema.lua

+ 9 - 1
graphql/introspection.lua

@@ -44,7 +44,15 @@ __Schema = types.object({
         resolve = function(schema)
         resolve = function(schema)
           return schema.directives
           return schema.directives
         end
         end
-      }
+      },
+
+      subscriptionType = {
+        description = 'If this server supports subscriptions, the type that subscription operations will be rooted at',
+        kind = __Type,
+        resolve = function(schema)
+          return schema:getSubscriptionType()
+        end
+       }
     }
     }
   end
   end
 })
 })

+ 5 - 0
graphql/schema.lua

@@ -26,6 +26,7 @@ function schema.create(config)
 
 
   self:generateTypeMap(self.query)
   self:generateTypeMap(self.query)
   self:generateTypeMap(self.mutation)
   self:generateTypeMap(self.mutation)
+  self:generateTypeMap(self.subscription)
   self:generateTypeMap(introspection.__Schema)
   self:generateTypeMap(introspection.__Schema)
   self:generateDirectiveMap()
   self:generateDirectiveMap()
 
 
@@ -99,6 +100,10 @@ function schema:getMutationType()
   return self.mutation
   return self.mutation
 end
 end
 
 
+function schema:getSubscriptionType()
+  return self.subscription
+end
+
 function schema:getTypeMap()
 function schema:getTypeMap()
   return self.typeMap
   return self.typeMap
 end
 end