-
for example, get all defined scalars as a list from graphql schema files scalar DateTime
scalar Date
scalar NonNegativeInt |
Beta Was this translation helpful? Give feedback.
Answered by
ardatan
Oct 13, 2021
Replies: 1 comment 2 replies
-
You can load and merge the type definitions; Then iterate over the definitions in Something like below to summarize; import { loadFilesSync } from '@graphql-tools/load';
import { mergeTypeDefs } from '@graphql-tools/merge';
import { join } from 'path';
import { Kind } from 'graphql';
const scalarTypeNames = new Set<string>();
const typeDefs = mergeTypeDefs(loadFilesSync(join(__dirname, './types')));
for (const definition of typeDefs.definitions) {
if (definition.kind === Kind.SCALAR_TYPE_DEFINITION) {
scalarTypeNames.add(definition.name.value);
}
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Diluka
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can load and merge the type definitions;
https://www.graphql-tools.com/docs/schema-merging#file-loading
Then iterate over the definitions in
DocumentNode
and filter out scalar type definitions likedefinition.kind === 'ScalarTypeDefinition'
.Something like below to summarize;