Skip to content

Instantly share code, notes, and snippets.

@dnd
Created October 10, 2017 22:57
Show Gist options
  • Save dnd/af16ed7b771cae3aabcfbac40c14c691 to your computer and use it in GitHub Desktop.
Save dnd/af16ed7b771cae3aabcfbac40c14c691 to your computer and use it in GitHub Desktop.
class Mutations::SigninUser < GraphQL::Function
SigninPayload = GraphQL::ObjectType.define do
name 'SigninPayload'
field :token, types.String, description: 'A JWT representing the authenticated user'
field :user, Types::User, description: 'The authenticated user
end
type SigninPayload
def call(_, args, ctx)
...
# This would be okay
SigninPayload.struct(token: '1234', user: user)
# This would fail, because :expiration is not a valid field of SigninPayload
SigninPayload.struct(token: '1234', expiration: '20171012')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment