Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make visitSchema (and other transform helper functions) top-level exports. #922

Closed
nderscore opened this issue Aug 8, 2018 · 2 comments
Closed
Labels
feature New addition or enhancement to existing solutions

Comments

@nderscore
Copy link

Use Case

Many of the schema transforms currently implemented and provided by graphql-tools use the visitSchema function under the hood to walk through the schema AST and transform it.

If you're creating a schema transform class that uses a transformSchema method, there's not much transforming you can do without a function like visitSchema. Given that, it makes sense to provide visitSchema as a supported feature for developers writing custom transforms.

I think it would be great if these functions were documented and exported as part of the main package. Without having them documented and exported at the top-level, the custom schema transform feature feels incomplete.

Workaround

Currently, in order to make use of visitSchema (and related functions), it must be imported from nested directories in the package:

import { visitSchema, VisitSchemaKind } from 'graphql-tools/dist/transforms/visitSchema';
import { fieldToFieldConfig, createResolveType } from 'graphql-tools/dist/stitching/schemaRecreation';
@ghost ghost added the feature New addition or enhancement to existing solutions label Aug 8, 2018
@slaymance
Copy link

Would love to see this feature be implemented as more use cases for transformSchema are found for our team. I'd go so far as to suggest building out tools like this even further.

We could create visitors for more fine-grained use cases while transforming schemas, like having visitors for specific types: visitInterfaces, visitUnions, visitEnums, etc. It reminds me a bit of the visitor methods of SchemaDirectiveVisitor. So I could possibly see these being methods we could utilize when building our own transform rules:

import { TransformSchemaVisitor } from 'graphql-tools';

...

class MyCustomSchemaTransform extends TransformSchemaVisitor {
  visitUnions(union) {
    union.isTransformed = true;
  }
}

@yaacovCR
Copy link
Collaborator

Rolled into #1306

@yaacovCR yaacovCR mentioned this issue Mar 30, 2020
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New addition or enhancement to existing solutions
Projects
None yet
Development

No branches or pull requests

3 participants