OneGraph / graphiql-explorer

Explorer plugin for GraphiQL
MIT License
907 stars 97 forks source link

Fix auto-tick issue when no subfields selected #58

Closed fatalbert3390 closed 4 years ago

fatalbert3390 commented 4 years ago

It would be nice in the case where when no subfields are selected under certain headings, running a query didn't automatically check every single box available for that heading. For example:

I drill into policyDetail > settings > items, but I don't tick any boxes under items. I would expect to get the same error when you don't expand any of the subfields under settings:

2020-07-30 20_40_08

However, you end up with this happening:

2020-07-30 20_32_31

All of the boxes under the items subfield are automatically checked when you run the policy, forcing you to have to go back and uncheck all of the subfields that were auto-selected.

Is there a way to make the behavior the same for fields with checkboxes vs. those without?

dwwoelfel commented 4 years ago

It should only add the first two leaf fields by default. You can control the behavior by providing the getDefaultFieldNames prop to the Explorer.

There is a default value defined in Explorer.js.

dwwoelfel commented 4 years ago

Thinking about this a bit more--the behavior you're seeing is when you run the query and it's caused by graphiql itself, not the Explorer. You should provide the custom getDefaultFieldNames prop to the GraphiQL component. You can use the default one we defined for the explorer: https://github.com/OneGraph/graphiql-explorer/blob/00881cc5b0f17a78d5ef8c5f64e0a85cbb6d5ec8/src/Explorer.js#L218