Skip to content

printSchema loses @directive information #869

Closed
@jzimmek

Description

@jzimmek

Hi, the printSchema function in "graphql/utilities/schemaPrinter" seems to forget the directives on field definitions.

import {buildSchema} from  "graphql/utilities/buildASTSchema"
import {printSchema} from  "graphql/utilities/schemaPrinter"

const schema = buildSchema(`
  type Person {
    id: ID!
    name: String @skip(if: true)
  }
  type Query {
    people: [Person]
  }
`)

console.info(printSchema(schema))

current output:

type Person {
  id: ID!
  name: String
}

type Query {
  people: [Person]
}

expected output:

type Person {
  id: ID!
  name: String @skip(if: true)
}
type Query {
  people: [Person]
}

Tested against graphql version: 0.9.6

I already digged a bit deeper into schemaPrinter and it seems that there is some special handling for directives going on:

1.) printSchema filters directives down to "skip", "include" and "deprecated"
2.) @ deperected seems to be handled

This is maybe better addressed in a separate issue, but I would like to add my own custom directives and get them also properly handled by printSchema.

Would you consider a PR for proper handling of spec directives as well as custom ones?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions