-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
finish updating to use type_system from parser
- Loading branch information
Showing
12 changed files
with
127 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
use cynic_parser::{ | ||
common::TypeWrappers, | ||
type_system::{ | ||
ids::FieldDefinitionId, | ||
storage::{FieldDefinitionRecord, ScalarDefinitionRecord, TypeRecord}, | ||
writer, | ||
}, | ||
TypeSystemDocument, | ||
}; | ||
|
||
pub(crate) fn add_builtins(schema: TypeSystemDocument) -> (TypeSystemDocument, FieldDefinitionId) { | ||
let mut writer = writer::TypeSystemAstWriter::update(schema); | ||
|
||
// Add the builtins | ||
for name in ["String", "Int", "Float", "Boolean", "ID"] { | ||
let name = writer.intern_string(name); | ||
writer.scalar_definition(ScalarDefinitionRecord { | ||
name, | ||
description: None, | ||
directives: Default::default(), | ||
span: Default::default(), | ||
name_span: Default::default(), | ||
}); | ||
} | ||
|
||
let typename_id = { | ||
let ty = { | ||
let name = writer.intern_string("String"); | ||
writer.type_reference(TypeRecord { | ||
name, | ||
name_start: Default::default(), | ||
wrappers: TypeWrappers::none().wrap_non_null(), | ||
span: Default::default(), | ||
}) | ||
}; | ||
let name = writer.intern_string("__typename"); | ||
writer.field_definition(FieldDefinitionRecord { | ||
name, | ||
name_span: Default::default(), | ||
ty, | ||
arguments: Default::default(), | ||
description: Default::default(), | ||
directives: Default::default(), | ||
span: Default::default(), | ||
}) | ||
}; | ||
|
||
(writer.finish(), typename_id) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.