public void Enter(INode node) { _ancestorStack.Push(node); if (node is SelectionSet) { _parentTypeStack.Push(GetLastType()); return; } if (node is Field field) { var parentType = _parentTypeStack.Peek().GetNamedType(); var fieldType = GetFieldDef(_schema, parentType, field); _fieldDefStack.Push(fieldType); var targetType = fieldType?.ResolvedType; _typeStack.Push(targetType); return; } if (node is Directive directive) { _directive = _schema.FindDirective(directive.Name); } if (node is Operation op) { IGraphType type = null; if (op.OperationType == OperationType.Query) { type = _schema.Query; } else if (op.OperationType == OperationType.Mutation) { type = _schema.Mutation; } else if (op.OperationType == OperationType.Subscription) { type = _schema.Subscription; } _typeStack.Push(type); return; } if (node is FragmentDefinition def1) { var type = _schema.FindType(def1.Type.Name); _typeStack.Push(type); return; } if (node is InlineFragment def) { var type = def.Type != null?_schema.FindType(def.Type.Name) : GetLastType(); _typeStack.Push(type); return; } if (node is VariableDefinition varDef) { var inputType = varDef.Type.GraphTypeFromType(_schema); _inputTypeStack.Push(inputType); return; } if (node is Argument argAst) { QueryArgument argDef = null; IGraphType argType = null; var args = GetDirective() != null?GetDirective()?.Arguments : GetFieldDef()?.Arguments; if (args != null) { argDef = args.Find(argAst.Name); argType = argDef?.ResolvedType; } _argument = argDef; _inputTypeStack.Push(argType); } if (node is ListValue) { var type = GetInputType().GetNamedType(); _inputTypeStack.Push(type); } if (node is ObjectField objectField) { var objectType = GetInputType().GetNamedType(); IGraphType fieldType = null; if (objectType is IInputObjectGraphType complexType) { var inputField = complexType.GetField(objectField.Name); fieldType = inputField?.ResolvedType; } _inputTypeStack.Push(fieldType); } }