Skip to content

Create sign up mutation#7

Merged
00dav00 merged 4 commits intomasterfrom
create-sign-up-mutation
Sep 5, 2019
Merged

Create sign up mutation#7
00dav00 merged 4 commits intomasterfrom
create-sign-up-mutation

Conversation

@00dav00
Copy link
Copy Markdown
Contributor

@00dav00 00dav00 commented Aug 31, 2019

  • Add signup mutation
  • Add url helper to create inline mutation

@00dav00 00dav00 force-pushed the create-sign-up-mutation branch 2 times, most recently from f163526 to af626ac Compare September 4, 2019 12:13
Add confirmation query as url params in email
@00dav00 00dav00 force-pushed the create-sign-up-mutation branch from af626ac to 3002a6f Compare September 4, 2019 12:15
Copy link
Copy Markdown
Member

@mcelicalderon mcelicalderon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, left some comments

Comment thread .gitignore Outdated
/*.sqlite3
/spec/dummy/db/development.sqlite3
/spec/dummy/db/test.sqlite3
/graphql_devise-0.1.0.gem
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tus will change with every version use *.gem instead

argument :config_name, String, required: false

def resolve(email:, **attrs)
redirect_url = attrs.delete(:confirm_success_url)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add kargs that are required directly in the resolve params so you don't have to do something like this

module Mutations
class SignUp < Base
argument :email, String, required: true
argument :name, String, required: false
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name is an attribute only on the dummy app, we need a way to configure that, or at least remove this one for now. You can use a custom mutation in the dummy app that extends from this one

resource.respond_to?(:confirmed_at)
end

def active_for_authentication?(resource)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one seems redundant when you can call that directly on resource

:email
end

# NOTE: Devise controller method, find a way to re use it
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could put it on the base mutation if some other mutation uses it

@@ -0,0 +1,19 @@
module GraphqlDevise
module MailerHelper
extend ActiveSupport::Concern
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary, right?

module MailerHelper
extend ActiveSupport::Concern

protected
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think helpers are usually just public

Comment thread lib/graphql_devise/rails/routes.rb Outdated
default_mutations = {
login: GraphqlDevise::Mutations::Login,
logout: GraphqlDevise::Mutations::Logout,
signUp: GraphqlDevise::Mutations::SignUp,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be snake_case

Comment thread lib/graphql_devise/rails/routes.rb Outdated
end

GraphqlDevise::Types::MutationType.field("#{mapping_name}_#{action}", mutation: used_mutation)
GraphqlDevise::Types::MutationType.field("#{mapping_name}_#{action.to_s.underscore}", mutation: used_mutation)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use snake case everywhere until it is required otherwise

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming here uses snake case, note "#{mapping_name}_

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, calling underscore here is not necessary as you changed line 22

GraphqlDevise::Types::MutationType.field("#{mapping_name}_#{action.to_s.underscore}", mutation: used_mutation)
end

Devise.mailer.send(:add_template_helper, GraphqlDevise::MailerHelper)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be an engine way not to need this, but is the method not public?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me take a look, but it is private doc

@00dav00 00dav00 force-pushed the create-sign-up-mutation branch from f013fc2 to 284f501 Compare September 5, 2019 13:32
@00dav00 00dav00 force-pushed the create-sign-up-mutation branch from 284f501 to aa9c806 Compare September 5, 2019 14:48
@00dav00 00dav00 merged commit ce61b29 into master Sep 5, 2019
@00dav00 00dav00 deleted the create-sign-up-mutation branch September 5, 2019 16:24
@mcelicalderon mcelicalderon added the enhancement New feature or request label Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants