var _Maybe = function(val) {
this.val = val;
}
var map = function(f, obj) {
return obj.map(f);
}
var Maybe = function(x) {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
field :authUser, AuthUserType do | |
argument :auth_token, !types.String | |
resolve -> (obj, args, ctx) do | |
User.find_by(auth_token: args[:auth_token]) | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AuthUserType = GraphQL::ObjectType.define do | |
name 'AuthUser' | |
description 'The authenticated user model type' | |
field :id, types.ID, 'The id of this user' | |
field :name, !types.String, 'The name of the user' | |
field :email, !types.String, 'The email of the user' | |
field :bio, types.String, 'The bio of the user' | |
field :created_at, types.String, 'The datetime string when the user was created' | |
field :events, types[EventType], 'The user events' | |
field :avatar, types.String, 'The user avatar' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
devise_for :users | |
mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "/api" | |
root to: redirect("/graphiql") | |
resources :api | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApiController < ApplicationController | |
def create | |
query_string = params[:query] | |
query_variables = ensure_hash(params[:variables]) | |
result = MeetupEventPlannerSchema.execute( | |
query_string, | |
variables: query_variables, | |
context: { } | |
) | |
render json: result |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Foo(who) { | |
this.me = who; | |
} | |
Foo.prototype.identify = function() { | |
return "I am " + this.me; | |
}; | |
function Bar(who) { | |
Foo.call(this,"Bar:" + who); |
var Foo = {
init: function(who) {
this.me = who;
},
identify: function() {
return "I am " + this.me;
}
}
Node configuration.
Update NPM version with the following command
npm update -g npm
Download NVM (Node Version Manager), which will help you to use the correct version of NodeJS
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.1/install.sh | bash
- Was the object called with the new keyword, if so use the newly created object.
- Was the object called with Call or Apply? If so, use that object.
- Was the object called by a containing / owning object? If so, use it.
- Default to the global.