Skip to content

Commit

Permalink
✨ - Tagged template literal support
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrolich committed May 14, 2024
1 parent 4cd3201 commit 0cecacb
Show file tree
Hide file tree
Showing 69 changed files with 2,626 additions and 2,104 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

We've found a bug for you!
snapshot_tests/operations/errors/fragmentWrongType.res:12:5-14:5

10 │ %graphql(`
11 │ query MyQuery @ppxConfig(templateTagImport: "gql", templateTagReturnT
│ ype: "bool") {
12 │ lists {
13 │  ...WrongFragmentName
14 │  }
15 │ }
16 │ `)
17 │

This has type: [> #WrongFragmentName]
But this function argument is expecting: [#ListFragment]
The second variant type does not allow tag(s) #WrongFragmentName

16 changes: 16 additions & 0 deletions snapshot_tests/operations/errors/fragmentWrongType.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%graphql(`
fragment ListFragment on Lists {
nullableOfNullable
nullableOfNonNullable
}
`)

module WrongFragmentName = ListFragment

%graphql(`
query MyQuery @ppxConfig(templateTagImport: "gql", templateTagReturnType: "bool") {
lists {
...WrongFragmentName
}
}
`)
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ var Wrapper = {

var Raw$5 = {};

var query$3 = "query MyQuery($arg1: String) {\nl1: lists {\n...ListFragment \n}\n\nl2: lists {\n__typename \n...ListFragment \n...ListFragment \n}\n\nl3: lists {\n__typename \nnullableOfNullable \n...ListFragment \n...ListFragment \n}\n\nl4: lists {\n__typename \nnullableOfNullable \n...InlineListFragment \n}\n\nl5: lists {\n...FragmentWithArgs \n}\n\n}\nfragment FragmentWithArgs on Lists {\n__typename \nlistWithArg(arg1: $arg1) \n}\nfragment InlineListFragment on Lists {\n__typename \nnullableOfNullable \nnullableOfNonNullable \n}\nfragment ListFragment on Lists {\n__typename \nnullableOfNullable \nnullableOfNonNullable \n}\n";
var query$3 = "query MyQuery($arg1: String) {\nl1: lists {\n...ListFragment \n}\n\nl2: lists {\n__typename \n...ListFragment \n...ListFragment \n}\n\nl3: lists {\n__typename \nnullableOfNullable \n...ListFragment \n...ListFragment \n}\n\nl4: lists {\n__typename \nnullableOfNullable \n...InlineListFragment \n}\n\nl5: lists {\n...FragmentWithArgs \n}\n\n}\nfragment FragmentWithArgs on Lists {\n__typename \nlistWithArg(arg1: $arg1) \n}\nfragment ListFragment on Lists {\n__typename \nnullableOfNullable \nnullableOfNonNullable \n}\nfragment InlineListFragment on Lists {\n__typename \nnullableOfNullable \nnullableOfNonNullable \n}\n";

function parse$5(value) {
var value$1 = value.l2;
Expand Down
261 changes: 130 additions & 131 deletions snapshot_tests/operations/expected/apollo/compile/tagged_template.res.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Generated by ReScript, PLEASE EDIT WITH CARE
'use strict';

var Gatsby = require("gatsby");
var ApolloClient = require("apollo-client");

function deepMerge(json1, param) {
Expand All @@ -13,23 +14,23 @@ var Graphql_ppx_runtime = {

var Raw = {};

var query = (graphql`
query {
variousScalars {
__typename
nullableString
string
nullableInt
int
nullableFloat
float
nullableBoolean
boolean
nullableID
id
}
}
`);
var query = graphql`query {
variousScalars {
__typename
nullableString
string
nullableInt
int
nullableFloat
float
nullableBoolean
boolean
nullableID
id
}

}
`;

function parse(value) {
var value$1 = value.variousScalars;
Expand Down Expand Up @@ -117,23 +118,23 @@ var MyTypes = {};

var Raw$1 = {};

var query$1 = (graphql`
query {
variousScalars {
__typename
nullableString
string
nullableInt
int
nullableFloat
float
nullableBoolean
boolean
nullableID
id
}
}
`);
var query$1 = graphql`query {
variousScalars {
__typename
nullableString
string
nullableInt
int
nullableFloat
float
nullableBoolean
boolean
nullableID
id
}

}
`;

function parse$1(value) {
var value$1 = value.variousScalars;
Expand Down Expand Up @@ -219,23 +220,23 @@ var MyQuery1a = {

var Raw$2 = {};

var query$2 = (graphql`
query {
variousScalars {
__typename
nullableString
string
nullableInt
int
nullableFloat
float
nullableBoolean
boolean
nullableID
id
}
}
`);
var query$2 = graphql`query {
variousScalars {
__typename
nullableString
string
nullableInt
int
nullableFloat
float
nullableBoolean
boolean
nullableID
id
}

}
`;

function parse$2(value) {
var value$1 = value.variousScalars;
Expand Down Expand Up @@ -321,23 +322,23 @@ var MyQuery1b = {

var Raw$3 = {};

var query$3 = (require("gatsby").graphql`
query {
variousScalars {
__typename
nullableString
string
nullableInt
int
nullableFloat
float
nullableBoolean
boolean
nullableID
id
}
}
`);
var query$3 = Gatsby.graphql`query {
variousScalars {
__typename
nullableString
string
nullableInt
int
nullableFloat
float
nullableBoolean
boolean
nullableID
id
}

}
`;

function parse$3(value) {
var value$1 = value.variousScalars;
Expand Down Expand Up @@ -423,23 +424,23 @@ var MyQuery2 = {

var Raw$4 = {};

var query$4 = (require("gatsby").graphql`
query {
variousScalars {
__typename
nullableString
string
nullableInt
int
nullableFloat
float
nullableBoolean
boolean
nullableID
id
}
}
`);
var query$4 = Gatsby.graphql`query {
variousScalars {
__typename
nullableString
string
nullableInt
int
nullableFloat
float
nullableBoolean
boolean
nullableID
id
}

}
`;

function parse$4(value) {
var value$1 = value.variousScalars;
Expand Down Expand Up @@ -525,23 +526,23 @@ var MyQuery3 = {

var Raw$5 = {};

var query$5 = (require("gatsby")`
query {
variousScalars {
__typename
nullableString
string
nullableInt
int
nullableFloat
float
nullableBoolean
boolean
nullableID
id
}
}
`);
var query$5 = Gatsby.graphql`query {
variousScalars {
__typename
nullableString
string
nullableInt
int
nullableFloat
float
nullableBoolean
boolean
nullableID
id
}

}
`;

function parse$5(value) {
var value$1 = value.variousScalars;
Expand Down Expand Up @@ -627,13 +628,12 @@ var MyQuery4 = {

var Raw$6 = {};

var query$6 = (require("gatsby")`
fragment ListFragment on Lists {
__typename
nullableOfNullable
nullableOfNonNullable
}
`);
var query$6 = Gatsby.graphql`fragment ListFragment on Lists {
__typename
nullableOfNullable
nullableOfNonNullable
}
`;

function parse$6(value) {
var value$1 = value.nullableOfNullable;
Expand Down Expand Up @@ -692,13 +692,13 @@ var ListFragment = {

var Raw$7 = {};

var query$7 = (require("gatsby")`
query MyQuery5 {
lists {
...ListFragment
}
}
`);
var query$7 = Gatsby.graphql`query MyQuery5 {
lists {
...ListFragment
}

}
${query$6}`;

function parse$7(value) {
return {
Expand Down Expand Up @@ -738,14 +738,13 @@ var MyQuery5 = {

var Raw$8 = {};

var query$8 = ((frag_0) => require("gatsby")`
query MyQuery6 {
lists {
...ListFragment
}
}
${frag_0}
`)(query$6);
var query$8 = Gatsby.graphql`query MyQuery6 {
lists {
...ListFragment
}

}
${query$6}`;

function parse$8(value) {
return {
Expand Down Expand Up @@ -785,13 +784,13 @@ var MyQuery6 = {

var Raw$9 = {};

var query$9 = (graphql`
query MyQuery7 {
lists {
...ListFragment
}
}
`);
var query$9 = graphql`query MyQuery7 {
lists {
...ListFragment
}

}
${query$6}`;

function parse$9(value) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,9 @@ l5: lists {
",
FragmentWithArgs.query,
),
InlineListFragment.query,
ListFragment.query,
),
ListFragment.query,
InlineListFragment.query,
)
let parse = (value): t => {
l1: {
Expand Down
Loading

0 comments on commit 0cecacb

Please sign in to comment.