forked from gitlabhq/gitlabhq
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bw-move-funtion-to-resolver' into 'master'
Upgrade GraphQL gem to 1.8.4 and replace echo function with a resolver See merge request gitlab-org/gitlab-ce!32016
- Loading branch information
Showing
11 changed files
with
58 additions
and
33 deletions.
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Resolvers | ||
class EchoResolver < BaseResolver | ||
argument :text, GraphQL::STRING_TYPE, required: true | ||
description 'Testing endpoint to validate the API with' | ||
|
||
def resolve(**args) | ||
username = context[:current_user]&.username | ||
|
||
"#{username.inspect} says: #{args[:text]}" | ||
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
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,24 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe Resolvers::EchoResolver do | ||
include GraphqlHelpers | ||
|
||
let(:current_user) { create(:user) } | ||
let(:text) { 'Message test' } | ||
|
||
describe '#resolve' do | ||
it 'echoes text and username' do | ||
expect(resolve_echo(text)).to eq %Q("#{current_user.username}" says: #{text}) | ||
end | ||
|
||
it 'echoes text and nil as username' do | ||
expect(resolve_echo(text, { current_user: nil })).to eq "nil says: #{text}" | ||
end | ||
end | ||
|
||
def resolve_echo(text, context = { current_user: current_user }) | ||
resolve(described_class, obj: nil, args: { text: text }, ctx: context) | ||
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
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