graphql-tag
dedent
graphql-tag | dedent | |
---|---|---|
7 | 3 | |
2,314 | 880 | |
0.1% | - | |
4.6 | 6.7 | |
3 months ago | 21 days ago | |
TypeScript | TypeScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
graphql-tag
-
How we migrated to Apollo Server 4
In Apollo Server 3, you could import the gql template literal tag directly from the apollo-server library. This template literal tag is provided by the graphql-tag library and allows parsing a GraphQL query string to an AST that can be used by Apollo and other GraphQL libraries.
-
Why do GQL strings need to be put through the gql function in JavaScript?
Handles parsing, some validation, normalizing and some sort of caching from what I can tell https://github.com/apollographql/graphql-tag/blob/main/src/index.ts
-
I thought I knew what I was doing
A common use of this feature is compilation of graphql queries, which looks like this.
- graphql-tag: A JavaScript template literal tag that parses GraphQL queries
-
Dealing with template strings
indentation in Relay.QL Relay and gql, graphql GraphQL template literals
-
Netflix open sources its GraphQL framework, written in Kotlin
By template strings I mean this (use of Javascript template literals in Apollo). We had a large SpringBoot REST API. Frontend added an Apollo server that simply called our backend and crammed it into a graphql response (ignoring all the work we did for pagination and caching). Later backend inherited this codebase and was forced to maintain it. Both teams spent many man hours on this endeavor with unclear tangible benefits.
-
Understanding Tagged Template Literal in JS
This features is so powerful that some awesome libraries were built on it such as Styled Components and graphql-tag.
dedent
-
All JavaScript and TypeScript features of the last 3 years explained
and so `dedent` would not strip any indentation. That is, `dedent` is meant to identify the maximal common leading indentation in the template as written by the developer, which should not depend on the values of the interpolands.
A stale GitHub issue on the dmnd/dedent repo has a real-world example where this matters and led to a subtle bug: https://github.com/dmnd/dedent/issues/22
-
I thought I knew what I was doing
There is also some other interesting use cases.
What are some alternatives?
web-mode - web template editing mode for emacs
node-sql-template-strings - ES6 tagged template strings for prepared SQL statements 📋
core-js - Standard Library
styled-components - Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
javascript - JavaScript Style Guide
vite - Next generation frontend tooling. It's fast!
webpack - A bundler for javascript and friends. Packs many modules into a few bundled assets. Code Splitting allows for loading parts of the application on demand. Through "loaders", modules can be CommonJs, AMD, ES6 modules, CSS, Images, JSON, Coffeescript, LESS, ... and your custom stuff.
apollo-server - 🌍 Spec-compliant and production ready JavaScript GraphQL server that lets you develop in a schema-first way. Built for Express, Connect, Hapi, Koa, and more.
type-fest - A collection of essential TypeScript types
html-es6cape - :zap: - Escape HTML special characters (including `)