Skip to content

Commit

Permalink
Reworked JSON scalar usage with StrawberryShake. (#6683)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Staib <[email protected]>
  • Loading branch information
david-driscoll and michaelstaib authored Nov 10, 2023
1 parent 793b9c2 commit fde3c9c
Show file tree
Hide file tree
Showing 79 changed files with 1,671 additions and 4,910 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ internal static void WriteFieldValue(
WriteList(writer, list);
break;

case JsonDocument doc:
doc.RootElement.WriteTo(writer);
break;

case JsonElement element:
element.WriteTo(writer);
break;

case string s:
writer.WriteStringValue(s);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface Character {
name: String!
friends("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): FriendsConnection
appearsIn: [Episode]
traits: JSON
height(unit: Unit): Float
}

Expand All @@ -19,6 +20,7 @@ type Droid implements Character {
friends("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): FriendsConnection
height(unit: Unit): Float
primaryFunction: String
traits: JSON
}

"A connection to a list of items."
Expand Down Expand Up @@ -47,6 +49,7 @@ type Human implements Character {
otherHuman: Human
height(unit: Unit): Float
homePlanet: String
traits: JSON
}

type Mutation {
Expand All @@ -68,6 +71,7 @@ type PageInfo {

type Query {
hero(episode: Episode! = NEW_HOPE): Character
heroByTraits(traits: JSON!): Character
heroes(episodes: [Episode!]): [Character!]
character(characterIds: [String]): [Character!]!
search(text: String): [SearchResult]
Expand Down Expand Up @@ -124,5 +128,7 @@ directive @stream("If this argument label has a value other than null, it will b

directive @tag(name: String!) repeatable on SCHEMA | SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION

scalar JSON

"The `Long` scalar type represents non-fractional signed whole 64-bit numeric values. Long can represent values between -(2^63) and 2^63 - 1."
scalar Long
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface Character {
name: String!
friends("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): FriendsConnection
appearsIn: [Episode]
traits: JSON
height(unit: Unit): Float
}

Expand All @@ -19,6 +20,7 @@ type Droid implements Character {
friends("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): FriendsConnection
height(unit: Unit): Float
primaryFunction: String
traits: JSON
}

"A connection to a list of items."
Expand Down Expand Up @@ -47,6 +49,7 @@ type Human implements Character {
otherHuman: Human
height(unit: Unit): Float
homePlanet: String
traits: JSON
}

type Mutation {
Expand All @@ -68,6 +71,7 @@ type PageInfo {

type Query {
hero(episode: Episode! = NEW_HOPE): Character
heroByTraits(traits: JSON!): Character
heroes(episodes: [Episode!]): [Character!]
character(characterIds: [String]): [Character!]!
search(text: String): [SearchResult]
Expand Down Expand Up @@ -124,5 +128,7 @@ directive @stream("If this argument label has a value other than null, it will b

directive @tag(name: String!) repeatable on SCHEMA | SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION

scalar JSON

"The `Long` scalar type represents non-fractional signed whole 64-bit numeric values. Long can represent values between -(2^63) and 2^63 - 1."
scalar Long
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface Character {
name: String!
friends("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): FriendsConnection
appearsIn: [Episode]
traits: JSON
height(unit: Unit): Float
}

Expand All @@ -19,6 +20,7 @@ type Droid implements Character {
friends("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): FriendsConnection
height(unit: Unit): Float
primaryFunction: String
traits: JSON
}

"A connection to a list of items."
Expand Down Expand Up @@ -47,6 +49,7 @@ type Human implements Character {
otherHuman: Human
height(unit: Unit): Float
homePlanet: String
traits: JSON
}

type Mutation {
Expand All @@ -68,6 +71,7 @@ type PageInfo {

type Query {
hero(episode: Episode! = NEW_HOPE): Character
heroByTraits(traits: JSON!): Character
heroes(episodes: [Episode!]): [Character!]
character(characterIds: [String]): [Character!]!
search(text: String): [SearchResult]
Expand Down Expand Up @@ -124,5 +128,7 @@ directive @stream("If this argument label has a value other than null, it will b

directive @tag(name: String!) repeatable on SCHEMA | SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION

scalar JSON

"The `Long` scalar type represents non-fractional signed whole 64-bit numeric values. Long can represent values between -(2^63) and 2^63 - 1."
scalar Long
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
type Query {
hero(episode: Episode! = NEW_HOPE): Character
heroByTraits(traits: JSON!): Character
heroes(episodes: [Episode!]): [Character!]
character(characterIds: [String]): [Character!]!
search(text: String): [SearchResult]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ interface Character {
name: String!
friends("Returns the first _n_ elements from the list." first: Int "Returns the elements in the list that come after the specified cursor." after: String "Returns the last _n_ elements from the list." last: Int "Returns the elements in the list that come before the specified cursor." before: String): FriendsConnection
appearsIn: [Episode]
traits: JSON
height(unit: Unit): Float
}

type Query {
hero(episode: Episode! = NEW_HOPE): Character
heroByTraits(traits: JSON!): Character
heroes(episodes: [Episode!]): [Character!]
character(characterIds: [String]): [Character!]!
search(text: String): [SearchResult]
Expand Down
Loading

0 comments on commit fde3c9c

Please sign in to comment.