Skip to content

How can I make a smart comment add a directive to the output? #1706

Closed
@mobinni

Description

@mobinni

Summary

I want to be able to comment on a table with any type of custom directive @pii and have that show up on the schema generation side.

I've tried multiple different approaches with a plugin, the closest I've gotten is to creating a directive in the schema, but I don't need that to happen as I stitch the schema into a larger one that has the directive defined. Really I just need to be able to tell the schema to take the comment of @pii and output it to the schema

function PIITag(builder: any) {
  builder.hook("GraphQLSchema", (schemaConfig: any, build: Build) => {
    return {
      ...schemaConfig,
      directives: [
        ...(schemaConfig.directives || []),
        build.newWithHooks(build.graphql.GraphQLDirective,
          { name: 'notPii', locations: ['FIELD_DEFINITION', 'OBJECT'], args: {} },
          { name: 'pii', locations: ['FIELD_DEFINITION', 'OBJECT'], args: {} }
        )
      ],
    }
  });
}

This doesn't lead to the desired output.

Desired output:

comment on function health_check() is E'@notPii true';
type Query {
  """
  Exposes the root query type nested one level down. This is helpful for Relay 1
  which can only query top level fields if they are in a particular form.
  """
  query: Query!
  healthCheck: Boolean @notPii
}

any help here would be appreciated

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