mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
fix(nanographql): support usage as normal fn (#27863)
This commit is contained in:
parent
5d2acd7ea2
commit
f37107862d
2
types/nanographql/index.d.ts
vendored
2
types/nanographql/index.d.ts
vendored
@ -6,4 +6,4 @@
|
||||
|
||||
export = nanographql;
|
||||
|
||||
declare function nanographql(query: TemplateStringsArray): (variables?: object) => string;
|
||||
declare function nanographql(query: TemplateStringsArray | string): (variables?: object) => string;
|
||||
|
||||
@ -1,10 +1,24 @@
|
||||
import gql = require('nanographql');
|
||||
const queryFactory = gql`
|
||||
|
||||
// TemplateStringArray query test
|
||||
const templateStringQueryFactory = gql`
|
||||
query($name: String!) {
|
||||
movie (name: $name) {
|
||||
releaseDate
|
||||
}
|
||||
}
|
||||
`;
|
||||
const query = queryFactory({ name: 'Back to the Future' });
|
||||
JSON.parse(query);
|
||||
const templatedQuery = templateStringQueryFactory({ name: 'Back to the Future' });
|
||||
JSON.parse(templatedQuery);
|
||||
|
||||
// string query test
|
||||
const stringField = 'movie';
|
||||
const strinQueryFactory = gql(`
|
||||
query($name: String!) {
|
||||
${stringField} (name: $name) {
|
||||
releaseDate
|
||||
}
|
||||
}
|
||||
`);
|
||||
const stringQuery = strinQueryFactory({ name: 'Back to the Future' });
|
||||
JSON.parse(stringQuery);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user