Questions tagged [graphql-ruby]

a Ruby implementation for GraphQL, a query language used for describing data requirements on complex application data models.

GraphQL is a query language created by Facebook for describing data requirements on complex application data models.

Website graphql-ruby.org

GitHub repository

143 questions
2
votes
1 answer

Using a List in a GraphQL Union type (in Ruby)

The GraphQL Ruby documentation shows how to define a union type: class Types::CommentSubject < Types::BaseUnion description "Objects which may be commented on" possible_types Types::Post, Types::Image # Optional: if this method is defined, it…
Beetle
  • 1,959
  • 16
  • 32
2
votes
0 answers

How to access object variable in visible? method graphql-ruby

I am trying to hide query class from schema from a user to whom fields are not visible. There are various levels of Users based on permissions. I can use visible?(ctx) method on class level where I have fields visibility is decided based on context.…
Nishutosh Sharma
  • 1,926
  • 2
  • 24
  • 39
2
votes
1 answer

graphql-ruby: how to get current user IP inside QueryType?

How to get current user's IP address inside QueryType? For example here: class QueryType < GraphQL::Schema::Object description "The query root of this schema" field :post, PostType, "Find a post by ID" do argument :id, ID end def…
Artem Kulakov
  • 29
  • 1
  • 5
2
votes
2 answers

How to set up an enum to allow multiple enums in a query? GraphQL Ruby

I have an enum, item_status.rb defined in app/graphql/graph/enums that looks something like this: Graph::Enums::ItemStatus = GraphQL::EnumType.define do name "ItemStatus" description "lorem ipsum" value "GOOD", "item is good", value: "good" …
espeon
  • 57
  • 1
  • 8
2
votes
1 answer

How to define a type holding an array of arrays?

With GraphQL-ruby I want to define a type for a field that holds data in the following structure: [ ["2016-06-07", 14134.84], ["2016-06-08", 14134.84], # ... ] How would I go for this? I tried module Types class PerformanceDataType <…
Flip
  • 6,233
  • 7
  • 46
  • 75
2
votes
1 answer

Graphql Ruby N + 1 Queries because of method calling another relationship

I am using the graphql and batch-loader gems and running into this N+1 query: I have a calendar appointment that belongs to an account, and when we display the appointment time we base it on the account's time zone. def appointment_time …
madav
  • 2,918
  • 1
  • 13
  • 17
2
votes
1 answer

Graphql-ruby: Need to restart Rails server every time when changing query_type or any other file

I'm using graphql 1.9.21 with rails 5.2.0 application. When I make changes to the graphql query_type or any other graphql related files such as(graphql_controller, type files, etc), I need to restart the rails server everytime. Otherwise, changes do…
Bibek Sharma
  • 3,210
  • 6
  • 42
  • 64
2
votes
2 answers

Can't get a simple broadcast with graphql-ruby subscriptions working

I have a barebones setup for update broadcasts with graphql-ruby over Action Cable. The client receives the initial payload on subscription fine. The client isn't receiving any updates and the update method of the subscription type isn't being…
Ates Goral
  • 137,716
  • 26
  • 137
  • 190
2
votes
0 answers

Implementing a GraphQL data provider for React Admin 3.7

I'm setting up a project with React Admin and GraphQL (powered by https://github.com/rmosolgo/graphql-ruby). By the looks of it, I should implement my own data provider. Looking through the docs, it appears the v3 way to do it is to return an object…
2
votes
1 answer

Unable to resolve interface type in GraphQL schema in test only

I've created an interface type, like: module UserErrorType include Types::BaseInterface definition_methods do def resolve_type(object, _ctx) ... end end end And a query that looks like: query { thing { errors { …
tom
  • 21
  • 3
2
votes
1 answer

Implementing union type with graphql-ruby

I'm trying to implement a union type with graphql-ruby. I followed the official documentation but got the error listed below. Here is my current code. module Types class AudioClipType < Types::BaseObject field :id, Int, null: false field…
K-Sato
  • 400
  • 7
  • 26
2
votes
0 answers

How is the clientMutationId used for optimistic updates in front ends?

I was reading about GraphQL mutations and had to decide wether to use Relay mutations or not in graphql-ruby. I stumbled upon the clientMutationId here https://graphql-ruby.org/api-doc/1.8.5/GraphQL/Schema/RelayClassicMutation.html clientMutationId…
23tux
  • 14,104
  • 15
  • 88
  • 187
2
votes
3 answers

Disabling GraphQL introspection requests on production

For company policies reasons I must disable the introspection feature of graphql-ruby gem (making the __schema requests fail / return 404). How do I achieve this? The application is based on Ruby on Rails version 5.2.2 and the graphql-ruby gem…
2
votes
1 answer

Unable to understand GraphQL Subscriptions using ActionCable with graphql-ruby gem

I am trying to implement GraphQL Subscriptions using ActionCable with graphql-ruby gem. I figured out from this link that GraphQL channel needs to be created to which clients needs to subscribe. Normally, in ActionCable, we will stream_from…
2
votes
2 answers

How do I use arguments that are passed to a Graphql ruby field to transform the result?

I am looking to do something similar to what is done in the graphql tutorial: https://graphql.org/learn/queries/#arguments I want to pass feet/meters to a scaler field to transform the result that is returned. { human(id: "1000") { name …
RMK
  • 877
  • 1
  • 9
  • 16
1 2
3
9 10