Hotchocolate: Hide field/property

Created on 11 May 2020  ·  4Comments  ·  Source: ChilliCream/hotchocolate

Hi,

I am using EF Core with hotchocolate. So for example for a company I use a query something like this:

[UsePaging]
[UseSelection]
[UseFiltering]
[UseSorting]
public IQueryable<Company> GetCompanies(
  [Service] ApplicationDbContext dbContext) =>
  dbContext.Companies;

So now assume I have a field in the table I do not want to transport, let's name this field SecretFlag. This is purely used in the backend and has nothing to do in the frontend (and should not be queryable).

We add to the Query by attribute ([ExtendObjectType(Name = "MyQuery")].

Thanks for any answer!

❓ question 🌶 hot chocolate

Most helpful comment

@sascha-andres You can either create a ObjectType and Ignore the field or you just use the attribute [GraphQLIngore] on the desired property on Company

All 4 comments

@sascha-andres You can either create a ObjectType and Ignore the field or you just use the attribute [GraphQLIngore] on the desired property on Company

Worked.

@PascalSenn thanks for your help

GraphQLIngore

[GraphQLIgnore] correct typo.

It should be in documentation.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nigel-sampson picture nigel-sampson  ·  5Comments

nigel-sampson picture nigel-sampson  ·  5Comments

acelot picture acelot  ·  4Comments

louisjrdev picture louisjrdev  ·  3Comments

PascalSenn picture PascalSenn  ·  5Comments