Struct apollo_smith::DocumentBuilder
source · pub struct DocumentBuilder<'a> { /* private fields */ }Expand description
DocumentBuilder is a struct to build an arbitrary valid GraphQL document
// fuzz/fuzz_targets/my_apollo_smith_fuzz_target.rs
#![no_main]
use libfuzzer_sys::fuzz_target;
use arbitrary::Unstructured;
use apollo_smith::DocumentBuilder;
fuzz_target!(|input: &[u8]| {
let mut u = Unstructured::new(input);
let gql_doc = DocumentBuilder::new(&mut u)?;
let document = gql_doc.finish();
let document_str = String::from(document);
// Your code here...
});Implementations§
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
sourcepub fn arguments_with_def(
&mut self,
args_def: &ArgumentsDef
) -> Result<Vec<Argument>>
pub fn arguments_with_def(
&mut self,
args_def: &ArgumentsDef
) -> Result<Vec<Argument>>
Create an arbitrary vector of Argument given ArgumentsDef
sourcepub fn argument_with_def(
&mut self,
input_val_def: &InputValueDef
) -> Result<Argument>
pub fn argument_with_def(
&mut self,
input_val_def: &InputValueDef
) -> Result<Argument>
Create an arbitrary Argument
sourcepub fn arguments_definition(&mut self) -> Result<ArgumentsDef>
pub fn arguments_definition(&mut self) -> Result<ArgumentsDef>
Create an arbitrary ArgumentsDef
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
sourcepub fn description(&mut self) -> Result<Description>
pub fn description(&mut self) -> Result<Description>
Create an arbitrary Description
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
sourcepub fn directives(
&mut self,
directive_location: DirectiveLocation
) -> Result<HashMap<Name, Directive>>
pub fn directives(
&mut self,
directive_location: DirectiveLocation
) -> Result<HashMap<Name, Directive>>
Create an arbitrary vector of Directive
sourcepub fn directive(
&mut self,
directive_location: DirectiveLocation
) -> Result<Option<Directive>>
pub fn directive(
&mut self,
directive_location: DirectiveLocation
) -> Result<Option<Directive>>
Create an arbitrary Directive given a directive location
sourcepub fn directive_def(&mut self) -> Result<DirectiveDef>
pub fn directive_def(&mut self) -> Result<DirectiveDef>
Create an arbitrary DirectiveDef
sourcepub fn directive_locations(&mut self) -> Result<HashSet<DirectiveLocation>>
pub fn directive_locations(&mut self) -> Result<HashSet<DirectiveLocation>>
Create an arbitrary HashSet of DirectiveLocation
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
sourcepub fn enum_type_definition(&mut self) -> Result<EnumTypeDef>
pub fn enum_type_definition(&mut self) -> Result<EnumTypeDef>
Create an arbitrary EnumTypeDef
sourcepub fn choose_enum(&mut self) -> Result<&EnumTypeDef>
pub fn choose_enum(&mut self) -> Result<&EnumTypeDef>
Choose an arbitrary EnumTypeDef in existings (already created) enum definitions
sourcepub fn arbitrary_variant<'b>(
&mut self,
enum_: &'b EnumTypeDef
) -> Result<&'b Name>
pub fn arbitrary_variant<'b>(
&mut self,
enum_: &'b EnumTypeDef
) -> Result<&'b Name>
Create an arbitrary variant Name given an enum
sourcepub fn enum_values_definition(&mut self) -> Result<HashSet<EnumValueDefinition>>
pub fn enum_values_definition(&mut self) -> Result<HashSet<EnumValueDefinition>>
Create an arbitrary EnumValueDefinition
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
sourcepub fn fragment_definition(&mut self) -> Result<FragmentDef>
pub fn fragment_definition(&mut self) -> Result<FragmentDef>
Create an arbitrary FragmentDef
sourcepub fn fragment_spread(
&mut self,
excludes: &mut Vec<Name>
) -> Result<Option<FragmentSpread>>
pub fn fragment_spread(
&mut self,
excludes: &mut Vec<Name>
) -> Result<Option<FragmentSpread>>
Create an arbitrary FragmentSpread, returns None if no fragment definition was previously created
sourcepub fn inline_fragment(&mut self) -> Result<InlineFragment>
pub fn inline_fragment(&mut self) -> Result<InlineFragment>
Create an arbitrary InlineFragment
sourcepub fn type_condition(&mut self) -> Result<TypeCondition>
pub fn type_condition(&mut self) -> Result<TypeCondition>
Create an arbitrary TypeCondition
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
sourcepub fn input_object_type_definition(&mut self) -> Result<InputObjectTypeDef>
pub fn input_object_type_definition(&mut self) -> Result<InputObjectTypeDef>
Create an arbitrary InputObjectTypeDef
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
sourcepub fn input_value(&mut self) -> Result<InputValue>
pub fn input_value(&mut self) -> Result<InputValue>
Create an arbitrary InputValue
pub fn input_value_for_type(&mut self, ty: &Ty) -> Result<InputValue>
sourcepub fn input_values_def(&mut self) -> Result<Vec<InputValueDef>>
pub fn input_values_def(&mut self) -> Result<Vec<InputValueDef>>
Create an arbitrary list of InputValueDef
sourcepub fn input_value_def(&mut self) -> Result<InputValueDef>
pub fn input_value_def(&mut self) -> Result<InputValueDef>
Create an arbitrary InputValueDef
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
sourcepub fn interface_type_definition(&mut self) -> Result<InterfaceTypeDef>
pub fn interface_type_definition(&mut self) -> Result<InterfaceTypeDef>
Create an arbitrary InterfaceTypeDef
sourcepub fn implements_interfaces(&mut self) -> Result<HashSet<Name>>
pub fn implements_interfaces(&mut self) -> Result<HashSet<Name>>
Create an arbitrary HashSet of implemented interfaces
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
sourcepub fn name_with_index(&mut self, index: usize) -> Result<Name>
pub fn name_with_index(&mut self, index: usize) -> Result<Name>
Create an arbitrary Name with an index included in the name (to avoid name conflict)
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
sourcepub fn object_type_definition(&mut self) -> Result<ObjectTypeDef>
pub fn object_type_definition(&mut self) -> Result<ObjectTypeDef>
Create an arbitrary ObjectTypeDef
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
sourcepub fn operation_definition(&mut self) -> Result<Option<OperationDef>>
pub fn operation_definition(&mut self) -> Result<Option<OperationDef>>
Create an arbitrary OperationDef taking the last SchemaDef
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
sourcepub fn scalar_type_definition(&mut self) -> Result<ScalarTypeDef>
pub fn scalar_type_definition(&mut self) -> Result<ScalarTypeDef>
Create an arbitrary ScalarTypeDef
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
sourcepub fn schema_definition(&mut self) -> Result<SchemaDef>
pub fn schema_definition(&mut self) -> Result<SchemaDef>
Create an arbitrary SchemaDef
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
sourcepub fn union_type_definition(&mut self) -> Result<UnionTypeDef>
pub fn union_type_definition(&mut self) -> Result<UnionTypeDef>
Create an arbitrary UnionTypeDef
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
sourcepub fn variable_definitions(&mut self) -> Result<Vec<VariableDef>>
pub fn variable_definitions(&mut self) -> Result<Vec<VariableDef>>
Create an arbitrary list of VariableDef
sourcepub fn variable_definition(&mut self) -> Result<VariableDef>
pub fn variable_definition(&mut self) -> Result<VariableDef>
Create an arbitrary VariableDef
source§impl<'a> DocumentBuilder<'a>
impl<'a> DocumentBuilder<'a>
sourcepub fn new(u: &'a mut Unstructured<'a>) -> Result<Self>
pub fn new(u: &'a mut Unstructured<'a>) -> Result<Self>
Create an instance of DocumentBuilder
sourcepub fn with_document(
u: &'a mut Unstructured<'a>,
document: Document
) -> Result<Self>
pub fn with_document(
u: &'a mut Unstructured<'a>,
document: Document
) -> Result<Self>
Create an instance of DocumentBuilder given a Document to be able to call
methods on DocumentBuilder and generate valid entities like for example an operation