The validateName function that is used to validate lots of schema parts is currently only checking that names are not reserved:
|
function validateName( |
|
context: SchemaValidationContext, |
|
node: { readonly name: string; readonly astNode: Maybe<ASTNode> }, |
|
): void { |
|
// Ensure names are valid, however introspection types opt out. |
|
if (node.name.startsWith('__')) { |
|
context.reportError( |
|
`Name "${node.name}" must not begin with "__", which is reserved by GraphQL introspection.`, |
|
node.astNode, |
|
); |
|
} |
|
} |
It should also check that the
name complies with
https://spec.graphql.org/October2021/#Name, e.g. by testing against the regex
/^(?!__)[A-Za-z_][A-Za-z0-9_]*$/.
Otherwise it's possible to construct schemas (via the constructor, not by parsing) that upon printing would lead to invalid syntax, or fields which could never be queried. (Not the case, see below)
The
validateNamefunction that is used to validate lots of schema parts is currently only checking that names are not reserved:graphql-js/src/type/validate.ts
Lines 206 to 217 in 6b253e7
It should also check that the
namecomplies with https://spec.graphql.org/October2021/#Name, e.g. by testing against the regex/^(?!__)[A-Za-z_][A-Za-z0-9_]*$/.Otherwise it's possible to construct schemas (via the constructor, not by parsing) that upon printing would lead to invalid syntax, or fields which could never be queried.(Not the case, see below)