Skip to content

Schema object is omitted when printed #1094

@sMorm

Description

@sMorm

Relevant Packages

@apollo/federation v0.33.3
@apollo/subgraph 0.1.2

To support the @contact directive, a schema element must be defined. When building a schema using buildSubgraphSchema and printing it via printSubgraphSchema the schema element is stripped without any directives applied.

Example Code

const { gql } = require("apollo-server");
const { buildSubgraphSchema } = require("@apollo/federation");
const { printSubgraphSchema } = require("@apollo/subgraph");
const typeDefs = gql`
  directive @contact(
    name: String!
    url: String!
    description: String!
  ) on SCHEMA

  extend type Query {
    hello: String
  }

  schema @contact(name: "hi", url: "https://hi.com", description: "hi") {
    query: Query
  }
`;

const schemaString = printSubgraphSchema(buildSubgraphSchema({ typeDefs }));
console.log(schemaString);

Expected Behavior

The expected value of schemaString.

directive @contact(name: String!, url: String!, description: String!) on SCHEMA

extend type Query {
  _service: _Service!
  hello: String
}

schema @contact(name: "hi", url: "https://hi.com", description: "hi") {
  query: Query
}

Actual Behavior

directive @contact(name: String!, url: String!, description: String!) on SCHEMA

extend type Query {
  _service: _Service!
  hello: String
}

Metadata

Metadata

Assignees

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