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

How to find operations that have a specific option enabled? #1284

Open
utajum opened this issue Aug 26, 2024 · 4 comments
Open

How to find operations that have a specific option enabled? #1284

utajum opened this issue Aug 26, 2024 · 4 comments

Comments

@utajum
Copy link

utajum commented Aug 26, 2024

Hello Pothos team,

I am currently working on a project where I need to identify all fields in my Pothos schema that have specific options enabled, such as the tracing option.

Could you please provide guidance or an example of how to programmatically find all fields that have the tracing option enabled?

Thank you for your assistance!

@hayes
Copy link
Owner

hayes commented Aug 28, 2024

Can you elaborate on the use case?

The original options for a type/field are attached as (type/field).extensions.pothosOptions in the built schema

@utajum
Copy link
Author

utajum commented Aug 28, 2024

I need to get a list of all fields that have an option enabled so I can do some external processing.

To my knowledge I have access to (type/field).extensions.pothosOptions only when a specific operation is called. Any way (method) to get a list of (type/field).extensions.pothosOptions for all at once?

@hayes
Copy link
Owner

hayes commented Aug 28, 2024

You can get all of the types in your schema by doing schema.getTypes(), and all of a types fields (if it's an object or interface) using type.getFields(). It should be pretty easy map over these to collect the options you need

@utajum
Copy link
Author

utajum commented Aug 28, 2024

Thank you for the reply, unfortunately getTypes() method does not exist on schema.

Can you provide an example?

Im doing

const schema = builder.toSchema();
schema.getTypes(); 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants