-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from baransu/feature/apollo-mode
Add -apollo-mode which adds __typename on every GraphQL Object in query
- Loading branch information
Showing
6 changed files
with
60 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
module MyQuery = [%graphql {| | ||
{ | ||
first: nestedObject { | ||
inner { | ||
inner { | ||
field | ||
} | ||
} | ||
} | ||
|
||
second: nestedObject { | ||
inner { | ||
inner { | ||
f1: field | ||
f2: field | ||
} | ||
} | ||
} | ||
} | ||
|}]; | ||
|
||
Jest.(describe("Apollo mode", () => { | ||
open Expect; | ||
open! Expect.Operators; | ||
|
||
test("Adds __typename to objects", () => { | ||
let typenameRegex = [%bs.re {|/__typename/g|}]; | ||
Js.log(MyQuery.query) | ||
MyQuery.query | ||
|> Js.String.match(typenameRegex) | ||
|> Belt.Option.map(_, Array.length) | ||
|> expect == Some(7); | ||
}); | ||
})); |
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,12 @@ | ||
module MyQuery: { | ||
type t = Js.t({ | ||
. | ||
first: Js.t({. inner: option(Js.t({. inner : option(Js.t({. field : string})) })) }), | ||
second: Js.t({. inner : option(Js.t({. inner : option(Js.t({. f1: string, f2: string})) })) }), | ||
}); | ||
|
||
let make: unit => Js.t({ . parse: Js.Json.t => t, query: string, variables: Js.Json.t }); | ||
let makeWithVariables: Js.t({.}) => Js.t({ . parse: Js.Json.t => t, query: string, variables: Js.Json.t }); | ||
|
||
let query: string; | ||
}; |
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