Last active
September 24, 2020 16:43
-
-
Save balazsorban44/352d5295f604fb4274bfc934937737a1 to your computer and use it in GitHub Desktop.
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
// I wish this file to be generated from my *.gql files | |
declare module '*/queries.gql' { | |
export const Something: string; | |
export const SomethingElse: 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
import {Something} from "./queries.gql" | |
console.log(Something) | |
/** | |
* Prints (minified or not) | |
* | |
* query Something { | |
* name | |
* id | |
* } | |
*/ | |
fetch("http://example.com/graphql", { | |
method: "POST", | |
headers: { | |
"Content-Type": "application-json" | |
}, | |
body: JSON.stringify({query: SomethingElse, variables: {var: ""}}) | |
}) |
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
query Something { | |
name | |
id | |
} | |
query SomethingElse($var: String!) { | |
somethingelse($var) { | |
phone | |
... SomeFragment | |
} | |
} | |
fragment SomeFragment { | |
address | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment