Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Niiice! I finally understand the origin of this JS syntax used in SQL queries and GraphQL:

sql`SELECT * FROM users WHERE id = ${userId}`

const q = gql` query GetUser { user(id: ${userId}) { name email } } `;



They're called "tagged template literals". Here's the docs:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: