-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create organization #68
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
94c00f3
feat: create mutation for RegisterOrganization
algibson1 3349fe3
feat: add field to call register_organization mutation
algibson1 391c78c
refactor: add custom validations for contact info to organization model
algibson1 b920db2
test: Test custom validations in organization model
algibson1 d9f3276
test: add skeleton tests for RegisterOrganization mutation
algibson1 5a26b51
test: Add query test
algibson1 0c17bb2
Merge branch 'main' of github.com:Refugee-Aid-Capstone/refugee_aid_be…
algibson1 a79cc9b
feat: Write resolve method to create an Organization
algibson1 9270d9d
fix: Remove comments, adjust criteria for when to raise an error on i…
algibson1 9a629cd
fix: change wording of a test title
algibson1 54c5cd2
test: test endpoint to register a new organization, sad path tests in…
algibson1 fc631b8
fix: adjust syntax for criteria to validate presence of contact info
algibson1 a048dd7
fix: remove comments, adjust expected error for no contact info given
algibson1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mutations | ||
class RegisterOrganization < BaseMutation | ||
null true | ||
|
||
type Types::OrganizationType | ||
|
||
argument :name, String, required: true | ||
argument :contact_phone, String, required: false | ||
argument :contact_email, String, required: false | ||
argument :street_address, String, required: false | ||
argument :website, String, required: false | ||
argument :city, String, required: true | ||
argument :state, String, required: true | ||
argument :zip, String, required: true | ||
argument :share_address, Boolean, required: false | ||
argument :share_phone, Boolean, required: false | ||
argument :share_email, Boolean, required: false | ||
|
||
|
||
def resolve(**args) | ||
location = Geocoder.search(address(args)) | ||
args[:latitude] = location.first.latitude | ||
args[:longitude] = location.first.longitude | ||
begin | ||
Organization.create!(args) | ||
rescue ActiveRecord::RecordInvalid => error | ||
raise GraphQL::ExecutionError, "#{error.message}" | ||
end | ||
end | ||
|
||
def address(args) | ||
[args[:street_address], args[:city], args[:state], args[:zip]].compact.join(', ') | ||
end | ||
end | ||
end |
This file contains 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
This file contains 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love how DRY
**args
makes this 🥳