Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make types public #1180

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions juniper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ mod ast;
pub mod executor;
mod introspection;
pub mod parser;
pub(crate) mod schema;
mod types;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tusharmath here types are mostly re-exported to the crate's root. If something is missing, I think it's better to add that to the re-exports, rather than making these modules public.

pub mod schema;
pub mod types;
mod util;
pub mod validation;
mod value;
Expand Down
12 changes: 6 additions & 6 deletions juniper/src/schema/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ pub struct RootNode<
/// Metadata for a schema
#[derive(Debug)]
pub struct SchemaType<'a, S> {
pub(crate) description: Option<Cow<'a, str>>,
pub(crate) types: FnvHashMap<Name, MetaType<'a, S>>,
pub(crate) query_type_name: String,
pub(crate) mutation_type_name: Option<String>,
pub(crate) subscription_type_name: Option<String>,
directives: FnvHashMap<String, DirectiveType<'a, S>>,
pub description: Option<Cow<'a, str>>,
pub types: FnvHashMap<Name, MetaType<'a, S>>,
pub query_type_name: String,
pub mutation_type_name: Option<String>,
pub subscription_type_name: Option<String>,
pub directives: FnvHashMap<String, DirectiveType<'a, S>>,
}

impl<'a, S> Context for SchemaType<'a, S> {}
Expand Down
2 changes: 1 addition & 1 deletion juniper/src/types/name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
};

#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Name(String);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tusharmath I don't like this change, because it breaks encapsulation for the Name type here and allow freely bypass its invariants. It's far better here to provide a meaningful constructor-function, which checks the invariants.

pub struct Name(pub String);

impl Name {
pub fn is_valid(input: &str) -> bool {
Expand Down
Loading