Closed toverux closed 4 years ago
yes I'm seeing the same issue. all the descriptions are gone.
I have the same problem.
The problem is probably introduced in https://github.com/ardatan/graphql-toolkit, since that library handles the schema loading etc.
also "description" fields are empty now in a generated graphql schema.json
Could you try with the following canary version?
1.11.3-alpha-aba86640.34
Version 1.11.3-alpha-aba86640.34
does not fix the issue for me.
@falkenhawk Could you share a reproduction on codesandbox so I can debug?
@falkenhawk ?
I'd love to, but I am swamped at the moment... I can share my codegen config file, if that's of any help:
overwrite: true
schema: ${GRAPHQL_URL:http://micro.test/api/graphql}
config:
namingConvention:
enumValues: change-case#upperCase
generates:
./graphql.schema.json:
plugins:
- introspection
packages/common/gen/graphql.fragments.json:
plugins:
- fragment-matcher
packages/common/src/service.graphql.ts:
plugins:
- typescript
hooks:
afterOneFileWrite:
- prettier --write
And I have comments attached to my fields in my schema e.g.
type User {
"Some description for the field"
something: Boolean
}
Descriptions are missing from both graphql.schema.json
(as "description" property of an entity) and service.graphql.ts
(as docblock comments, as @toverux reported in the first post):
{
"name": "something",
// in 1.9.1: "description": "Some description for the field",
"description": "",
"args": [],
"type": { (...) },
"isDeprecated": false,
"deprecationReason": null
},
It seems that "descriptions" are not being retrieved properly from an url endpoint. The last version I had this working was 1.9.1, so I am staying on that for the time being.
Checked the latest version, and @ardatan added tests in graphql-toolkit.
It seems to work: (tested introspection, schema-ast and typescript plugins)
@falkenhawk @toverux @leethree
Can you please share a reproduction in a sandbox?
Here is test cases I used from a PR on graphql-toolkit; https://github.com/ardatan/graphql-toolkit/pull/446 This PR doesn't contain any changes on actual code but tests
Thank you for the effort, your reproduction works and tests are passing for a json endpoint.
I tried 1.11.3-alpha-19673fd9.101
but descriptions are still gone, when using URL endpoint.
Maybe someone could help with setting up a sandbox reproduction with URL endpoint...
https://github.com/ardatan/graphql-toolkit/blob/master/packages/loaders/url/tests/url-loader.spec.ts We have tests for URL endpoint as well. It has descriptions and a custom schema declaration to be specific.
I looked at the tests, then at the url loader package, and everything looks fine there, when encapsulated. I can only suspect an integration issue, which is not covered by existing tests.
E.g. the schema
returned from urlloader is a result of makeRemoteExecutableSchema
function call, whereas json-file loader uses buildClientSchema
function internally - and maybe then generators have troubles handling different structures. My guess might be totally wrong, but I could not find anything else for the time being...
Could you please share a reproduction repo or codesandbox to get on the same page?
@ardatan https://codesandbox.io/s/solitary-butterfly-yhmfn
in index.js
:
const typeDefs = gql`
"""
All our queries
"""
type Query {
"Hello description"
hello: String
}
`;
./codegen.yml
overwrite: true
schema: ${GRAPHQL_URL:http://0.0.0.0:4000/}
generates:
./graphql.schema.json:
plugins:
- introspection
./graphql.types.ts:
plugins:
- typescript
diff between 1.9.1 and 1.12.1:
./graphql.types.ts
@@ -6,19 +6,15 @@
Boolean: boolean,
Int: number,
Float: number,
- /** The `Upload` scalar type represents a file upload. */
Upload: any,
};
-
export enum CacheControlScope {
Public = 'PUBLIC',
Private = 'PRIVATE'
}
-/** All our queries */
export type Query = {
__typename?: 'Query',
- /** Hello description */
hello?: Maybe<Scalars['String']>,
};
./graphql.schema.json
@@ -9,11 +9,11 @@
{
"kind": "OBJECT",
"name": "Query",
- "description": "All our queries",
+ "description": "",
"fields": [
{
"name": "hello",
- "description": "Hello description",
+ "description": "",
"args": [],
"type": {
"kind": "SCALAR",
@@ -871,17 +871,7 @@
{
"kind": "SCALAR",
"name": "Upload",
- "description": "The `Upload` scalar type represents a file upload.",
- "fields": null,
- "inputFields": null,
- "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.",
+ "description": null,
"fields": null,
"inputFields": null,
"interfaces": null,
@@ -891,37 +881,6 @@
],
"directives": [
{
- "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": [
any update on this? I think we have a pretty solid repro here ⬆️
The GraphQL framework I'm using comes with a way to dump the schema to JSON. When I run the codegen against that JSON file, I get docblocks. When I run the codegen against a URL, I don't get docblocks.
This indicates that maybe there is a problem with the introspection query that is being sent to the server? This is the query that is being run when I dump the schema to JSON: https://github.com/absinthe-graphql/absinthe/blob/v1.4.16/priv/graphql/introspection.graphql.
I can confirm that this issue happens because of an incorrect configuration codegen passes to graphql-toolkit
.
It seems like the url-loader is fetching everything correctly, and building the schema with buildClientSchema
as we need to. But something with printSchemaWithDirectives
causes description to turn into comments (marked as #
)
Then codegen then gets it without it, so the output has it missing.
I'm working on a fix now.
@toverux @rzane @leethree @falkenhawk @anfinil @koenpunt
Can you please try 1.13.2-alpha-4638c86d.112+4638c86d
? It should fix that issue. I tested it with @falkenhawk 's reproduction and it seems to work fine now.
@dotansimha I tried it. The generated schema has documentations now. Thanks!
Fixed in v1.13.2
Describing the bug
In versions <1.10.0, types generated by the
typescript
plugin had docblocks with descriptions coming from the API.After upgrading to latest, those comments are missing from the generated file. I found that this happens since 1.10.0 but nothing in the Releases tab or issues seems to mention any change about this.
My diff looks like this, for hundreds of types:
Of course, I verified that the descriptions are still in the API, and when I'm coming back to versions prior to ^1.10.0, doc blocks are back.
To reproduce
My
codegen.yml
config file:Dependencies (managed by yarn, lock file confirms latest version is installed) :