In all the graphql
literature the recommended way of creating a graphql
type is like so:
import {gql} from 'graphql-tag'
const query = const typeDefs = gql`
type Book {
title: String
author: String
}
# The "Query" type is the root of all GraphQL queries.
type Query {
books: [Book]
}
`;
I have never seen an argument passed to a function without parenthesis in javascript before now so I did some tests
const fn = (n) => n+1
// pass a number
fn1; // Reference error can't find fn1
// Pass a string
fn'1' // Syntax error Unexpected string literal '1'
// Pass a template
fn`1` // => "11"
What sort of black magic is happening in the engine that makes this possible with template strings? I'm guessing it has to do with how template strings are interpreted by the js engine, presumably wrapping them implicitly in parenthesis, but I don't know.