Skip to content

Instantly share code, notes, and snippets.

scalar JSON
scalar Date
# Type for Movies
type Movie {
_id: String
createdAt: Date
user: User
userId: String
name: String
@SachaG
SachaG / intl_directive.js
Last active December 11, 2020 08:49
GraphQL Intl Directive
class IntlDirective extends SchemaDirectiveVisitor {
visitFieldDefinition(field, details) {
const fieldName = field.name;
field.resolve = async function (...args) {
// get document, GraphQL arguments, and query context
const [ doc, graphQLArguments, context ] = args;
// get the locale either from the query's arguments, or from the context
const locale = graphQLArguments.locale || context.locale;
// get the field containing translations
const intlField = doc[`${name}_intl`];
"stations" : [
{
"name" : "Shinjuku Gyoenmae front",
"distance" : 549,
"distanceFormatted" : "0.5 km",
"duration" : "3 mins",
"location" : {
"lng" : 139.71069,
"lat" : 35.688588
},
@SachaG
SachaG / lines.json
Created April 24, 2018 05:47
tokyo metro lines
[
{ "id": 11301, "name": { "ja": "JR東海道本線(東京~熱海)", "en": "JR Tokaido Main Line (Tokyo - Atami)" } },
{ "id": 11302, "name": { "ja": "JR山手線", "en": "JR Yamanote Line" } },
{ "id": 11303, "name": { "ja": "JR南武線", "en": "JR Nambu Line" } },
{ "id": 11305, "name": { "ja": "JR武蔵野線", "en": "JR Musashino Line" } },
{ "id": 11306, "name": { "ja": "JR横浜線", "en": "JR Yokohama Line" } },
{ "id": 11308, "name": { "ja": "JR横須賀線", "en": "JR Yokosuka Line" } },
{ "id": 11311, "name": { "ja": "JR中央本線(東京~塩尻)", "en": "JR Chuo Main Line (Tokyo ~ Shiojiri)" } },
{ "id": 11312, "name": { "ja": "JR中央線(快速)", "en": "JR Chuo Line (fast)" } },
{ "id": 11313, "name": { "ja": "JR中央・総武線", "en": "JR Chuo Sobu Line" } },

Using Variables (devel branch)

Field-specific queries work by adding “extra” query parts to a specialy created formNewExtraQuery HoC when inserting new documents; or to the withDocument HoC when editing an existing document. In either case, the main query will be called with the following extraTerms argument:

const extraTerms = {
  documentId,
  currentUser,
  view: `${collectionName}ExtraQueryView` // where collectionName is the collection the form belongs to
# Type for Movies
type Movie {
_id: String
createdAt: Date
user: User
userId: String
name: String
year: String
review: String
}
/*
Generate the appropriate fragment for the current form, then
wrap the main Form component with the necessary HoCs while passing
them the fragment.
This component is itself wrapped with:
- withCurrentUser
- withApollo (used to access the Apollo client for form pre-population)
@SachaG
SachaG / stuff.md
Last active September 13, 2017 13:49
Vulcan Forum Example Testing

Accounts

  • Create new account

Posts

  • Upvote a post
  • Downvote a post
# Front-End
preact
mithril
inferno
elm
skate
cycle
avalon
sencha