Skip to content

Commit

Permalink
chore: use allow_list in favour of whitelist (tailcallhq#1104)
Browse files Browse the repository at this point in the history
  • Loading branch information
ologbonowiwi authored Feb 4, 2024
1 parent 2c5b337 commit baac160
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions autogen/src/gen_gql_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use schemars::schema::{
use tailcall::config;

static GRAPHQL_SCHEMA_FILE: &str = "generated/.tailcallrc.graphql";
static DIRECTIVE_WHITELIST: [(&str, Entity, bool); 12] = [
static DIRECTIVE_ALLOW_LIST: [(&str, Entity, bool); 12] = [
("server", Entity::Schema, false),
("upstream", Entity::Schema, false),
("http", Entity::FieldDefinition, false),
Expand Down Expand Up @@ -304,7 +304,7 @@ fn write_input_type(
extra_it: &mut BTreeMap<String, ExtraTypes>,
types_added: &mut HashSet<String>,
) -> std::io::Result<()> {
let name = match input_whitelist_lookup(&name, extra_it) {
let name = match input_allow_list_lookup(&name, extra_it) {
Some(name) => name,
None => return Ok(()),
};
Expand Down Expand Up @@ -413,16 +413,16 @@ fn write_property(
Ok(())
}

fn directive_whitelist_lookup(name: &str) -> Option<(&'static str, Entity, bool)> {
for (nm, entity, is_repeatable) in DIRECTIVE_WHITELIST.iter() {
fn directive_allow_list_lookup(name: &str) -> Option<(&'static str, Entity, bool)> {
for (nm, entity, is_repeatable) in DIRECTIVE_ALLOW_LIST.iter() {
if name.to_lowercase() == nm.to_lowercase() {
return Some((*nm, *entity, *is_repeatable));
}
}
None
}

fn input_whitelist_lookup<'a>(
fn input_allow_list_lookup<'a>(
name: &'a str,
extra_it: &mut BTreeMap<String, ExtraTypes>,
) -> Option<&'a str> {
Expand All @@ -447,7 +447,7 @@ fn write_directive(
written_directives: &mut HashSet<String>,
extra_it: &mut BTreeMap<String, ExtraTypes>,
) -> std::io::Result<()> {
let (name, entity, is_repeatable) = match directive_whitelist_lookup(&name) {
let (name, entity, is_repeatable) = match directive_allow_list_lookup(&name) {
Some(entity) => entity,
None => return Ok(()),
};
Expand Down

0 comments on commit baac160

Please sign in to comment.