Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression: Custom graphql directives missing from introspection json in v1.12.0+ #3915

Closed
falkenhawk opened this issue Apr 22, 2020 · 4 comments
Labels
waiting-for-answer Waiting for answer from author

Comments

@falkenhawk
Copy link

falkenhawk commented Apr 22, 2020

Describe the bug

Regression: Custom graphql directives missing from introspection json in v1.12.0+

To Reproduce
Steps to reproduce the behavior:
https://codesandbox.io/s/awesome-dewdney-bv2wc

  1. My GraphQL schema:
  directive @testDirective on FIELD_DEFINITION

  type Query {
    hello: String @testDirective
  }
  1. My GraphQL operations:
# Put your operations here
  1. My codegen.yml config file:
overwrite: true
schema: ${GRAPHQL_URL:http://0.0.0.0:4000/}
generates:
  ./graphql.schema.json:
    plugins:
      - introspection

diff between 1.11.2 and 1.13.3:

./graphql.schema.json

@@ -9,11 +9,11 @@
       {
         "kind": "OBJECT",
         "name": "Query",
-        "description": "",
+        "description": null,
         "fields": [
           {
             "name": "hello",
-            "description": "",
+            "description": null,
             "args": [],
             "type": {
               "kind": "SCALAR",
@@ -848,20 +848,20 @@
       {
         "kind": "ENUM",
         "name": "CacheControlScope",
-        "description": "",
+        "description": null,
         "fields": null,
         "inputFields": null,
         "interfaces": null,
         "enumValues": [
           {
             "name": "PUBLIC",
-            "description": "",
+            "description": null,
             "isDeprecated": false,
             "deprecationReason": null
           },
           {
             "name": "PRIVATE",
-            "description": "",
+            "description": null,
             "isDeprecated": false,
             "deprecationReason": null
           }
@@ -877,59 +877,10 @@
         "interfaces": null,
         "enumValues": null,
         "possibleTypes": null
-      },
-      {
-        "kind": "SCALAR",
-        "name": "Int",
-        "description": "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.",
-        "fields": null,
-        "inputFields": null,
-        "interfaces": null,
-        "enumValues": null,
-        "possibleTypes": null
       }
     ],
     "directives": [
       {
-        "name": "testDirective",
-        "description": "",
-        "locations": [
-          "FIELD_DEFINITION"
-        ],
-        "args": []
-      },
-      {
-        "name": "cacheControl",
-        "description": "",
-        "locations": [
-          "FIELD_DEFINITION",
-          "OBJECT",
-          "INTERFACE"
-        ],
-        "args": [
-          {
-            "name": "maxAge",
-            "description": "",
-            "type": {
-              "kind": "SCALAR",
-              "name": "Int",
-              "ofType": null
-            },
-            "defaultValue": null
-          },
-          {
-            "name": "scope",
-            "description": "",
-            "type": {
-              "kind": "ENUM",
-              "name": "CacheControlScope",
-              "ofType": null
-            },
-            "defaultValue": null
-          }
-        ]
-      },
-      {
         "name": "skip",
         "description": "Directs the executor to skip this field or fragment when the `if` argument is true.",
         "locations": [

Expected behavior

custom graphql directives (testDirective) back where there should be

Environment:

  • OS:
  • @graphql-codegen/...:
  • NodeJS:

Additional context

@dotansimha
Copy link
Owner

description has changed and was fixed, and it has nothing to do with directives...

If you are loading your GraphQL schema from a URL, directives will be removed, and it's related to GraphQL and not to codegen: graphql/graphql-js#869

@falkenhawk am I missing something?

@dotansimha dotansimha added the waiting-for-answer Waiting for answer from author label Apr 28, 2020
@falkenhawk
Copy link
Author

falkenhawk commented Apr 28, 2020

@dotansimha description values are irrelevant here, I've just posted full diff. It's about testDirective missing from directives array in the resulting introspection json...

     "directives": [
       {
-        "name": "testDirective",
-        "description": "",
-        "locations": [
-          "FIELD_DEFINITION"
-        ],
-        "args": []
-      },

@falkenhawk
Copy link
Author

falkenhawk commented Apr 28, 2020

Maybe it's okay that custom directives are not included anymore (since v1.12.0) in the generated schema json, I can't tell tbh... but it's also confusing that SOME directives are still there ('skip', 'included', 'deprecated' - they are from graphql spec)

@dotansimha
Copy link
Owner

dotansimha commented Apr 30, 2020

Oh I see, but I'm not sure it's related to codegen. GraphQL has special treatments for those directives you mentioned, that's why they are part of the spec.
If you wish to have directives - use schema file instead of an endpoint, because that's skip introspection and builds the schema from the source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-for-answer Waiting for answer from author
Projects
None yet
Development

No branches or pull requests

2 participants