(directives, schemaMember, previewsPerVersion)
| 77 | } |
| 78 | |
| 79 | async function getPreview(directives, schemaMember, previewsPerVersion) { |
| 80 | if (!directives.length) return |
| 81 | |
| 82 | // it's possible for a schema member to be deprecated and under preview |
| 83 | const previewDirective = directives.filter((dir) => dir.name.value === 'preview') |
| 84 | if (!previewDirective.length) return |
| 85 | |
| 86 | // catch any schema members that are under more than one preview (none currently) |
| 87 | if (previewDirective.length > 1) |
| 88 | console.log(`more than one preview found for ${schemaMember.name}`) |
| 89 | |
| 90 | // an input object's input field may have a ListValue directive that is not relevant to previews |
| 91 | if (previewDirective[0].arguments[0].value.kind !== 'StringValue') return |
| 92 | |
| 93 | const previewName = previewDirective[0].arguments[0].value.value |
| 94 | |
| 95 | const preview = previewsPerVersion.find((p) => p.toggled_by.includes(previewName)) |
| 96 | if (!preview) console.error(`cannot find "${previewName}" in graphql_previews.yml`) |
| 97 | |
| 98 | return preview |
| 99 | } |
| 100 | |
| 101 | // the docs use brackets to denote list types: `[foo]` |
| 102 | // and an exclamation mark to denote non-nullable types: `foo!` |
nothing calls this directly
no outgoing calls
no test coverage detected