Skip to content

Commit

Permalink
Update print_schema to support ARGUMENT_DEFINITION and INPUT_FIELD_DE…
Browse files Browse the repository at this point in the history
…FINITION directives

Reviewed By: tyao1

Differential Revision: D52316296

fbshipit-source-id: 43bed1bd784fdaed4ba4fa966485be0f9ae3d74b
  • Loading branch information
James Wren authored and facebook-github-bot committed Dec 20, 2023
1 parent 5c82d16 commit 5cf0af1
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/crates/schema-print/src/print_schema.rs
Expand Up @@ -376,6 +376,7 @@ impl<'schema, 'writer, 'curent_writer> Printer<'schema, 'writer> {
if let Some(default) = &arg.default_value {
write!(self.writer(), " = {}", default,)?;
}
self.print_directive_values(&arg.directives)?;
}
write!(self.writer(), ")")
}
Expand Down Expand Up @@ -406,6 +407,7 @@ impl<'schema, 'writer, 'curent_writer> Printer<'schema, 'writer> {
if let Some(default) = &arg.default_value {
write!(self.writer(), " = {}", default,)?;
}
self.print_directive_values(&arg.directives)?;
self.print_new_line()?;
}
write!(self.writer(), "}}")
Expand Down
Expand Up @@ -3,6 +3,7 @@ directive @source(schema: String, name: String) on OBJECT | INTERFACE | ENUM
directive @ref_type(schema: String, name: String) on FIELD_DEFINITION
directive @extern_type(schema: String, name: String) on INTERFACE
directive @fetchable(field_name: String) on OBJECT
directive @fbid on ARGUMENT_DEFINITION | FIELD_DEFINITION | INPUT_FIELD_DEFINITION

schema {
query: Query
Expand Down Expand Up @@ -77,9 +78,25 @@ interface Image implements Resource & Node {
url: String
thumbnail: String
}

input UserRequest {
user_id: ID! @fbid
other_user_ids: [ID!] = [] @fbid
}

type UserResponse {
user_id: ID! @fbid
name: String
}

type UsernameQuery {
fetch_user_name(user_id: ID @fbid): String
}
==================================== OUTPUT ===================================
directive @extern_type(schema: String, name: String) on INTERFACE

directive @fbid on ARGUMENT_DEFINITION | FIELD_DEFINITION | INPUT_FIELD_DEFINITION

directive @fetchable(field_name: String) on OBJECT

directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
Expand All @@ -92,6 +109,8 @@ directive @source(schema: String, name: String) on OBJECT | INTERFACE | ENUM

directive @extern_type(schema: String, name: String) on INTERFACE

directive @fbid on ARGUMENT_DEFINITION | FIELD_DEFINITION | INPUT_FIELD_DEFINITION

directive @fetchable(field_name: String) on OBJECT

directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
Expand Down Expand Up @@ -138,6 +157,15 @@ type User implements XIGHuman @fetchable(field_name: "id") {
story(story: XIGStoryInput = {id: 123, name: "instagram_story"}): XIGStory
}

type UserResponse {
user_id: ID! @fbid
name: String
}

type UsernameQuery {
fetch_user_name(user_id: ID @fbid): String
}

interface XIGHuman @source(schema: "instagram", name: "Human") {
name: String
}
Expand Down Expand Up @@ -168,6 +196,11 @@ interface Resource implements Node {
url: String
}

input UserRequest {
user_id: ID! @fbid
other_user_ids: [ID!] = [] @fbid
}

type XIGStory @fetchable(field_name: "id") @source(schema: "instagram", name: "Story") {
id: ID
name: String
Expand Down
Expand Up @@ -2,6 +2,7 @@ directive @source(schema: String, name: String) on OBJECT | INTERFACE | ENUM
directive @ref_type(schema: String, name: String) on FIELD_DEFINITION
directive @extern_type(schema: String, name: String) on INTERFACE
directive @fetchable(field_name: String) on OBJECT
directive @fbid on ARGUMENT_DEFINITION | FIELD_DEFINITION | INPUT_FIELD_DEFINITION

schema {
query: Query
Expand Down Expand Up @@ -76,3 +77,17 @@ interface Image implements Resource & Node {
url: String
thumbnail: String
}

input UserRequest {
user_id: ID! @fbid
other_user_ids: [ID!] = [] @fbid
}

type UserResponse {
user_id: ID! @fbid
name: String
}

type UsernameQuery {
fetch_user_name(user_id: ID @fbid): String
}

0 comments on commit 5cf0af1

Please sign in to comment.