You can define GraphQL directives by placing a @gqlDirective
before a:
- Function declaration
- Arrow function declaration
/**
* @gqlDirective
You can annotate parts of your Grats GraphQL schema with directives (link to define directives) using the @gqlAnnotate
docblock tag.
/**
* @gqlQueryField
* @gqlAnnotate myDirective
*/
export function greet(): string {
return "Hello";
}
One day at work I noticed a stray }
at the bottom of a page of our product. I went searching for it, and found the culprit: during a refactor a }
which had previously been used to enclose an expression within some JSX had been left behind. It occurred to me that this was likely a common error and something that could be linted for. I slapped together a quick rule that reported certain syntax characters that tend to get left behind (like )
, ;
, >
, }
or })
) as a lint error.
I ran the rule on the code base and to my surprise there were a few hundred examples of stray characters in our UI. A few weeks later a similar bug cropped up in a separate codebase at work where I had not enabled the rule. My colleague Brad Zacher remembered my lint rule and suggested it get added there as well. However, at that point an engineer on the Flow team suggested maybe Flow could just make some of these characters a syntax error. They did and uncovered and fixed a few
This document (DRAFT) describes GraphQL directives used to annotate a GraphQL schema which is backed by JavaScript resolvers. Its goal is to encode enough information that a complete GraphQL executor for the schema can be inferred directly from the GraphQL Schema Definition Language (SDL) document. This approach is especially attractive for implementation-first servers where the GraphQL schema and how to execute it can be inferred directly from the resolver code itself.
Ideally this scheme can enabling decoupling and interoperability between tools. For example:
{ | |
"$schema": "http://json-schema.org/draft-07/schema#", | |
"title": "ConfigFile", | |
"anyOf": [ | |
{ | |
"description": "Base case configuration (mostly of OSS) where the project have single schema, and single source directory", | |
"type": "object", | |
"required": [ | |
"language" | |
], |
Relay Liver Resolvers are an experimental Relay feature which lets you extend your server’s GraphQL schema to include additional client state. For example, you might want to expose data from a legacy state management solution or from IndexDB to your Relay components.
Your experience writing GraphQL resolvers on the server should mostly apply to writing Live Resolvers. The main distinction is that Live Resolvers are reactive. Instead of just reading a single values, Live Resolvers model a value that might change over time, similar to an observable.
This rule lints for non-colocated fragment spreads within queries or fragments. In other words, situations where a fragment is spread in module A, but the module (B) that defines that fragment is not imported by module A. It does not lint subscriptions or mutations. This catches:
The easiest way to tell if a fragment is unused is to remove the line containing the lint error, run js1 rebuild relay
, the
'use strict'; | |
const {ROOT_DIR} = require('../../utils/config/index.js'); | |
var fs = require('fs'); | |
const OSS_DIR = `${ROOT_DIR}/xplat/js/RKJSModules/Libraries/Relay/oss`; | |
const COMPILER_TARGETS_FILE = `${ROOT_DIR}/fbcode/relay/oss/crates/relay-compiler/TARGETS`; | |
const COMPILER_CARGO_FILES = [ | |
`${ROOT_DIR}/fbcode/relay/oss/crates/relay-compiler/Cargo.toml`, | |
`${ROOT_DIR}/fbcode/relay/oss/Cargo.oss.lock`, | |
]; |
const EQUALITY_OPERATORS = new Set(['==', '===', '!=', '!==']); | |
module.exports = { | |
meta: { | |
messages: { | |
constant: 'Constant condition.', | |
coalescingNeverNullish: 'Constant condition. Value can never be nullish.', | |
coalescingAlwaysNullish: | |
'Constant condition. Value will always be nullish.', | |
}, |
╭─[23:32]: jordaneldredge at Jordans-MacBook-Pro in ~/projects/skin-scrapers/niko-niko.net | |
╰─➤ find . | grep -i zip | wc -l | |
218 | |
╭─[23:32]: jordaneldredge at Jordans-MacBook-Pro in ~/projects/skin-scrapers/niko-niko.net | |
╰─➤ find . | grep -i zip | |
./winamp/Zel.ZIP | |
./winamp/shin.zip | |
./winamp/rasen7.zip | |
./winamp/naus.ZIP |