Bladeren bron

Remove subscriptions (for now);

bjorn 9 jaren geleden
bovenliggende
commit
4e7eabf6e9
4 gewijzigde bestanden met toevoegingen van 9 en 56 verwijderingen
  1. 4 17
      graphql/introspection.lua
  2. 0 8
      graphql/schema.lua
  3. 0 1
      graphql/types.lua
  4. 5 30
      tests/introspection.lua

+ 4 - 17
graphql/introspection.lua

@@ -12,7 +12,6 @@ local function resolveDirective(directive)
   local res = {}
   if directive.onQuery then table.insert(res, 'QUERY') end
   if directive.onMutation then table.insert(res, 'MUTATION') end
-  if directive.onSubscription then table.insert(res, 'SUBSCRIPTION') end
   if directive.onField then table.insert(res, 'FIELD') end
   if directive.onFragmentDefinition then table.insert(res, 'FRAGMENT_DEFINITION') end
   if directive.onFragmentSpread then table.insert(res, 'FRAGMENT_SPREAD') end
@@ -28,7 +27,7 @@ local function mapToList(m)
 end
 local __Schema, __Directive, __DirectiveLocation, __Type, __Field, __InputValue,__EnumValue, TypeKind, __TypeKind, SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, astFromValue, printAst, printers
 local DirectiveLocation = {
-  QUERY =  'QUERY', MUTATION =  'MUTATION', SUBSCRIPTION =  'SUBSCRIPTION', FIELD =  'FIELD', FRAGMENT_DEFINITION =  'FRAGMENT_DEFINITION', FRAGMENT_SPREAD =  'FRAGMENT_SPREAD', INLINE_FRAGMENT =  'INLINE_FRAGMENT'
+  QUERY =  'QUERY', MUTATION =  'MUTATION', FIELD =  'FIELD', FRAGMENT_DEFINITION =  'FRAGMENT_DEFINITION', FRAGMENT_SPREAD =  'FRAGMENT_SPREAD', INLINE_FRAGMENT =  'INLINE_FRAGMENT'
 }
 
 __Schema = types.object({
@@ -36,7 +35,7 @@ __Schema = types.object({
   description =
     'A GraphQL Schema defines the capabilities of a GraphQL server. It ' ..
     'exposes all available types and directives on the server, as well as ' ..
-    'the entry points for query, mutation, and subscription operations.',
+    'the entry points for query and mutation operations.',
   fields = function() return {
     types = {
       description = 'A list of all types supported by this server.',
@@ -57,16 +56,9 @@ __Schema = types.object({
       kind = __Type,
       resolve = function(schema) return schema:getMutationType() end
     },
-    subscriptionType = {
-      description = 'If this server support subscription, the type that ' ..
-                   'subscription operations will be rooted at.',
-      kind = __Type,
-      resolve = function(schema) return schema:getSubscriptionType() end
-    },
     directives = {
       description = 'A list of all directives supported by this server.',
-      kind = 
-        types.nonNull(types.list(types.nonNull(__Directive))),
+      kind = types.nonNull(types.list(types.nonNull(__Directive))),
       resolve = function(schema) return schema.directives end
     }
   } end
@@ -123,8 +115,7 @@ __Directive = types.object({
       kind = types.nonNull(types.boolean),
       resolve = function(d) return
         d.locations:find(DirectiveLocation.QUERY) ~= nil or
-        d.locations:find(DirectiveLocation.MUTATION) ~= nil or
-        d.locations:find(DirectiveLocation.SUBSCRIPTION) ~= nil end
+        d.locations:find(DirectiveLocation.MUTATION) ~= nil end
     },
     onFragment = {
       deprecationReason = 'Use `locations`.',
@@ -156,10 +147,6 @@ __DirectiveLocation = types.enum({
       value = DirectiveLocation.MUTATION,
       description = 'Location adjacent to a mutation operation.'
     },
-    SUBSCRIPTION = {
-      value = DirectiveLocation.SUBSCRIPTION,
-      description = 'Location adjacent to a subscription operation.'
-    },
     FIELD = {
       value = DirectiveLocation.FIELD,
       description = 'Location adjacent to a field.'

+ 0 - 8
graphql/schema.lua

@@ -10,9 +10,6 @@ function schema.create(config)
   if config.mutation then
     assert(type(config.mutation) == 'table', 'mutation must be a table')
   end
-  if config.subscription then
-    assert(type(config.subscription) == 'table', 'subscription must be a table')
-  end
   
   local self = {}
   for k, v in pairs(config) do
@@ -66,7 +63,6 @@ function schema.create(config)
 
   generateTypeMap(self.query)
   generateTypeMap(self.mutation)
-  generateTypeMap(self.subscription)
   generateTypeMap(introspection.__Schema)
 
   self.directives = self.directives or {
@@ -107,10 +103,6 @@ function schema:getMutationType()
   return self.mutation
 end
 
-function schema:getSubscriptionType()
-  return self.subscription
-end
-
 function schema:getTypeMap()
   return self.typeMap
 end

+ 0 - 1
graphql/types.lua

@@ -268,7 +268,6 @@ function types.directive(config)
     arguments = config.arguments,
     onQuery = config.onQuery or false,
     onMutation = config.onMutation or false,
-    onSubscription = config.onSubscription or false,
     onField = config.onField or false,
     onFragmentDefinition = config.onFragmentDefinition or false,
     onFragmentSpread = config.onFragmentSpread or false,

+ 5 - 30
tests/introspection.lua

@@ -5,13 +5,11 @@ local util = require 'graphql.util'
 local cjson = require 'cjson'
 local schema = require 'tests/data/todo'
 
-
 local introspection_query = [[
   query IntrospectionQuery {
     __schema {
       queryType { name }
       mutationType { name }
-      subscriptionType { name }
       types {
         ...FullType
       }
@@ -158,7 +156,6 @@ local introspection_expected_json = [[
       "queryType": {
         "name": "Query"
       },
-      "subscriptionType": null,
       "types": [
         {
           "description": null,
@@ -478,7 +475,7 @@ local introspection_expected_json = [[
           "possibleTypes": null
         },
         {
-          "description": "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.",
+          "description": "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query and mutation operations.",
           "enumValues": null,
           "fields": [
             {
@@ -532,18 +529,7 @@ local introspection_expected_json = [[
                 "name": "__Type",
                 "ofType": null
               }
-            },
-            {
-              "args": [],
-              "deprecationReason": null,
-              "description": "If this server support subscription, the type that subscription operations will be rooted at.",
-              "isDeprecated": false,
-              "name": "subscriptionType",
-              "type": {
-                "kind": "OBJECT",
-                "name": "__Type",
-                "ofType": null
-              }
+            }
             },
             {
               "args": [],
@@ -1221,12 +1207,6 @@ local introspection_expected_json = [[
               "isDeprecated": false,
               "name": "MUTATION"
             },
-            {
-              "deprecationReason": null,
-              "description": "Location adjacent to a subscription operation.",
-              "isDeprecated": false,
-              "name": "SUBSCRIPTION"
-            },
             {
               "deprecationReason": null,
               "description": "Location adjacent to a field.",
@@ -1284,32 +1264,27 @@ describe('introspection', function()
     if v.fields ~= cjson.null then table.sort(v.fields, compare_by_name) end
     if v.enumValues ~= cjson.null then table.sort(v.enumValues, compare_by_name) end
   end
-  
+
   it('basic json equality test', function()
       assert.are.same(cjson.decode('{"a":1,    "b":2}'),{b = 2, a = 1})
   end)
-  
+
   it('root nodes are set', function()
       assert.is.truthy(response.__schema)
       assert.is.truthy(response.__schema.directives)
       assert.is.truthy(response.__schema.mutationType)
       assert.is.truthy(response.__schema.queryType)
-      assert.is.truthy(response.__schema.subscriptionType)
       assert.is.truthy(response.__schema.types)
   end)
 
   it('mutationType match', function()
     assert.are.same(expected.__schema.mutationType, response.__schema.mutationType)
   end)
-  
+
   it('queryType match', function()
     assert.are.same(expected.__schema.queryType, response.__schema.queryType)
   end)
 
-  it('subscriptionType match', function()
-    assert.are.same(expected.__schema.subscriptionType, response.__schema.subscriptionType)
-  end)
-
   it('root types are same', function()
     local expected = util.map(expected.__schema.types, function ( t ) return t.name end)
     local response = util.map(response.__schema.types, function ( t ) return t.name end)