Hotchocolate: unknown scalar type and directive shows up in the schema

Created on 15 Nov 2019  路  9Comments  路  Source: ChilliCream/hotchocolate

I have a simple schema that I didn't include custom scalar or directive but they show up in my schema. I don't understand why they show up nor do I know what they are and how to exclude them if it's the library's default behaviour.

Here's my schema:

directive @cost(
  complexity: Int! = 1
  multipliers: [MultiplierPath!]
) on FIELD_DEFINITION

type Author {
  id: ID!
  name: String!
}

type Book {
  author: Author!
  chapters: Int!
  id: Int!
  pages: Int!
  title: String!
}

scalar MultiplierPath

type Mutation {
  book(author: String, chapters: Int!, pages: Int!, title: String): Book
}

type Query {
  book(id: Int!): Book
  books: [Book!]!
}

scalar MultiplierPath and directive @cost.... are the unwanted/unknown declaration in the schema. Here's a link to my code https://github.com/pmbanugo/graphql-intro-aspnet-core/tree/in-progress

### Steps to reproduce the behavior:

  1. create a new asp.net core 3 project
  2. add an object type and a query field.
  3. start the app and check the schema.

OR

Check my code listed above

Expected behavior
Schema should only include what I define

bug

All 9 comments

The issue is that we always register the cost directive that then brings in the scalar. I will fix that.

I have found your issue. We are adding the cost directive along with skip and include. I will issue a fix on the 10.x branch.

I think we will have this version out at the end of this week... I will give you a ping on this one.

Awesome!

This one is fixed with 10.3.0-preview.9.

For version 10 we did not want to break too much so we added an option:

ISchema schema = SchemaBuilder.New()
    ....
    .ModifyOptions(o => o.RemoveUnreachableTypes = true)
    .Create();

By default in version 10 the types are not trimmed down.

The reason fro this is that many people have schema snapshot tests and we did not want to break those.

For version 11 we will make trimming the default.

Still present on 10.4.2

@m4ss1m0g have set the Option?

@m4ss1m0g have set the Option?

Sorry I read that you fixed it in version 1.3 preview and I thought it was fixed in version 1.4 without the option.
When I added the option the scalar type goes away.

In version 11.0.0 we have this option set by default.

Was this page helpful?
0 / 5 - 0 ratings