-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for query variables and parameterized mutations.
- Loading branch information
Showing
13 changed files
with
183 additions
and
54 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 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
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
require_relative 'queries/root_query' | ||
require_relative 'types/invoice_type' | ||
|
||
require_relative 'queries/query' | ||
require_relative 'mutations/mutation' | ||
|
||
DummySchema = GraphQL::Schema.define do | ||
query RootQuery | ||
max_depth 5 | ||
query Query | ||
mutation Mutation | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
CreateInvoiceMutation = GraphQL::Relay::Mutation.define do | ||
name 'createInvoice' | ||
|
||
input_field :fee_in_cents, !types.Int | ||
|
||
return_type types[InvoiceType] | ||
|
||
resolve ->(_object, inputs, _ctx) { | ||
[ | ||
OpenStruct.new( | ||
id: 1231, | ||
fee_in_cents: inputs[:fee_in_cents] | ||
) | ||
] | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require_relative './create_invoice_mutation' | ||
|
||
Mutation = GraphQL::ObjectType.define do | ||
name 'Mutation' | ||
|
||
field :createInvoice, field: CreateInvoiceMutation.field | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Query = GraphQL::ObjectType.define do | ||
name 'Query' | ||
|
||
field :invoices, types[InvoiceType] do | ||
argument :ids, types[types.Int] | ||
description 'Find Invoices' | ||
resolve ->(_obj, args, _ctx) { | ||
args[:ids].map do |id| | ||
OpenStruct.new( | ||
id: id, | ||
fee_in_cents: 20_000 | ||
) | ||
end | ||
} | ||
end | ||
end |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
InvoiceType = GraphQL::ObjectType.define do | ||
name 'Invoice' | ||
description 'An Invoice' | ||
field :id, !types.ID | ||
field :id, !types.Int | ||
field :fee_in_cents, types.Int | ||
end |