Skip to content

Filtering a source schema also filters that schema's SDK #3367

Open
@leemhenson

Description

@leemhenson

Describe the bug
I want to filter a source schema so that some of it's members don't appear in my stitched schema. I think there are two ways of doing that:

  1. applying the filter transform on the source
  2. applying a root filter

When I try option 1, it works in that my stitched schema doesn't show those members. However, if I attempt to use the source's sdk from a custom resolver's context, I find those members are also filtered out and I can't query it.

When I try option 2, the Typescript declarations file is not emitted to .mesh/index.d.ts. This obviously kills all the typescript code in my project that depends on those types.

To Reproduce
Steps to reproduce the behavior:

Sandbox for option 1: https://codesandbox.io/s/hungry-montalcini-57ge6?file=/resolver.ts

You can see there are no members available on the AuthorService.Query type. If you comment out the transforms in the meshrc and rerun yarn build, the type is then populated.

Sandbox for option 2: https://codesandbox.io/s/condescending-swanson-9n0ux?file=/.mesh/schema.graphql

If you run yarn build you will see that no typescript declarations are emitted into the .mesh directory.

Expected behavior

I can see an argument for saying that transforms applied to the source schema should be reflected in that source schema's context sdk. If that's the case, root transforms must correctly emit the typescript declarations. Alternatively, it seems equally valid to say that the context sdk should be a true reflection of the upstream schema, and source transforms should only apply during the stitching.

Environment:

  • OS: MacOS 11.6
  • "@graphql-mesh/cli": "^0.44.4"
  • "@graphql-mesh/graphql": "^0.20.9"
  • "@graphql-mesh/transform-filter-schema": "^0.14.5"
  • NodeJS: 14

Metadata

Metadata

Assignees

No one assigned

    Labels

    stage/4-pull-requestA pull request has been opened that aims to solve the issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions