Skip to content

Instantly share code, notes, and snippets.

import {
GraphQLObjectType, GraphQLList, GraphQLString, GraphQLInt, GraphQLBoolean,
} from 'graphql'
import {attributeFields, resolver} from 'graphql-sequelize';
import db from '../../models'
module.exports = modelName => modelRelationFunc => {
const relationMethods = {
listOf: (gqlRelationType, options={}) => ({
defmodule Hyr.Command do
@moduledoc """
Define a command struct and an associated GraphQL mutation.
## Example
defmodule Hyr.Shifts.Opening.Commands.CancelOpeningEmployer do
use Hyr.Command
alias Hyr.Shifts.Opening.Schema.Opening
import * as AbsintheSocket from "@absinthe/socket";
import {Socket as PhoenixSocket} from "phoenix";
import {createFetcher, createSubscriber} from "@absinthe/socket-relay";
let instance = null
const errorFun = error => console.warn(error)
export default class RelayEnvironmentService {
static init(params) {
@ssomnoremac
ssomnoremac / get_schema.js
Created December 8, 2017 03:10
get your graphql schema
var fetch = require('node-fetch');
var fs = require('fs');
const {
buildClientSchema,
introspectionQuery,
printSchema,
} = require('graphql/utilities');
console.log(introspectionQuery);
@ssomnoremac
ssomnoremac / commanded_mutations.ex
Last active November 15, 2017 18:16
Proposal Module definition of Mutation/Command
# In each Command module
defmodule Hyr.Shifts.Opening.Commands.CancelOpening do
use Hyr.Commanded
input_object :cancel_opening_input_object do
field :opening_id, non_null(:id)
field :employer_id, non_null(:id)
end
[info] Sent 200 in 354ms
[debug] INCOMING "doc" on "__absinthe__:control" to Absinthe.Phoenix.Channel
Transport: Phoenix.Transports.WebSocket
Parameters: %{"query" => "subscription { newOpening {\n spots\n \temployerId\n \tsiteId\n }\n}", "variables" => nil}
[debug] ABSINTHE schema=Hyrbak.Schema variables=nil
---
subscription { newOpening {
spots
employerId
siteId
defmodule BlogPhoenix.Context do
@moduledoc """
This module is just a regular plug that can look at the conn struct and build
the appropriate absinthe context.
"""
@behaviour Plug
import Plug.Conn
def init(opts), do: opts
(FunctionClauseError) no function clause matching in Absinthe.Resolution.Projector.project/5
(absinthe) lib/absinthe/resolution/projector.ex:5: Absinthe.Resolution.Projector.project([%Absinthe.Blueprint.Document.Field{alias: nil, argument_data: %{}, arguments: [], complexity: nil, directives: [], errors: [], flags: %{}, name: "__typename", schema_node: %Absinthe.Type.Field{__private__: [], __reference__: nil, args: %{}, complexity: nil, default_value: nil, deprecation: nil, description: "The name of the object type currently being queried.", identifier: nil, middleware: [{{Absinthe.Resolution, :call}, #Function<0.862031/2 in Absinthe.Introspection.Field.meta/1>}], name: "__typename", type: :string}, selections: [], source_location: %Absinthe.Blueprint.Document.SourceLocation{column: nil, line: 3}, type_conditions: []}], nil, [%Absinthe.Blueprint.Document.Field{alias: nil, argument_data: %{id: "U2hpZnQ6MTIzZTQ1NjctZTg5Yi0xMmQzLWE0NTYtNDI2NjU1NDQwMDAw"}, arguments: [%Absinthe.Blueprint.Input.Argument{er
import React from 'react';
import {
View,
Image,
ListView,
ScrollView,
Text,
TouchableHighlight,
TouchableNativeFeedback,
TouchableOpacity,
import React from 'react'
import { TextInput, View } from 'react-native'
import theme from './theme'
const Input = (props) => (
const styles = {
inlineWrapper: {
flex: inlineLabel ? .5 : 1,
height: inlineLabel ? theme.FormGroup.height - theme.FormGroup.borderWidth*2 : theme.FormGroup.height,