public function assetTypeHasField(AbstractType $objectType, AstFieldInterface $ast) { /** @var AbstractObjectType $objectType */ if (!(TypeService::isObjectType($objectType) || TypeService::isInputObjectType($objectType)) || !$objectType->hasField($ast->getName())) { throw new ResolveException(sprintf('Field "%s" not found in type "%s"', $ast->getName(), $objectType->getNamedType()->getName()), $ast->getLocation()); } }
public function validate($data, $ruleInfo) { if (!is_string($ruleInfo)) { return false; } switch ($ruleInfo) { case TypeService::TYPE_ANY: return true; case TypeService::TYPE_ANY_OBJECT: return is_object($data); case TypeService::TYPE_CALLABLE: return is_callable($data); case TypeService::TYPE_BOOLEAN: return is_bool($data); case TypeService::TYPE_ARRAY: return is_array($data); case TypeService::TYPE_STRING: return TypeFactory::getScalarType($ruleInfo)->isValidValue($data); case TypeService::TYPE_GRAPHQL_TYPE: return TypeService::isGraphQLType($data); case TypeService::TYPE_OBJECT_TYPE: return TypeService::isObjectType($data); case TypeService::TYPE_ARRAY_OF_OBJECT_TYPES: return $this->isArrayOfObjectTypes($data); case TypeService::TYPE_ARRAY_OF_FIELDS_CONFIG: return $this->isArrayOfFields($data); case TypeService::TYPE_OBJECT_INPUT_TYPE: return TypeService::isInputObjectType($data); case TypeService::TYPE_ENUM_VALUES: return $this->isEnumValues($data); case TypeService::TYPE_ARRAY_OF_INPUT_FIELDS: return $this->isArrayOfInputFields($data); case TypeService::TYPE_ANY_INPUT: return TypeService::isInputType($data); case TypeService::TYPE_ARRAY_OF_INTERFACES: return $this->isArrayOfInterfaces($data); default: return false; } }