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

Returning an array graphQL

I'm currently trying to learn GraphQL but running into a problem. The problem is possibly not understanding the right way in writing my types. When I had my user type as module Types UserType = GraphQL::ObjectType.define do name 'User' …
Yama
  • 401
  • 1
  • 8
  • 22
2
votes
0 answers

Is `orphan_types` the only way to specify possible resolve types for an interface?

The ruby-graphql documentation says the following about resolve types for interfaces: ...a schema finds it types by traversing its fields, starting with query, mutation and subscription. If an object is never the return type of a field, but only…
Paul Holden
  • 850
  • 1
  • 8
  • 24
2
votes
1 answer

How can I inherit arguments from InputObject type in graphql-ruby?

I want to inherit common arguments from one input object type. I tried below code but it didn't work anyone has other solution? module TodoInputBase def self.included(input) argument :content, types.String argument :due_by, types.String …
Vimox Shah
  • 99
  • 1
  • 9
2
votes
1 answer

how can I pass multipart form-data and file upload using graphql-ruby at serverside?

below code is for mutation field :companyUpdate, Types::CompanyType do argument :id, !types.ID argument :file, Types::FileType resolve -> (obj, args, ctx) { company = ::Network::Company.find(args[:id]) company.update!(logo:…
2
votes
2 answers

GraphQL Ruby N+1 Batching Issue

I am using GraphQL in Ruby with the Batch & QueryResolver gems. They work fantastic except for this issue and can't seem to figure out why this may be happening. It seems to be loading "all relationships" then loading "first: X" relationships…
Jonathan Reyes
  • 1,387
  • 1
  • 10
  • 23
2
votes
0 answers

Creating join multiple associations using GraphQL & Relay

I am using GraphQL Ruby and making it compatible with Relay. I am trying to find the correct way of creating records in a join table using Relays node IDs. I know I can take an array of node IDs and get look up each object using…
CWitty
  • 4,488
  • 3
  • 23
  • 40
2
votes
0 answers

Rails Graphql pundit response error message

This is my code: application_controller.rb class ApplicationController < ActionController::API include Pundit end post_type.rb Types::QueryType = GraphQL::ObjectType.define do name 'Query' field :posts, types[Types::PostType] do resolve…
Dean
  • 415
  • 1
  • 5
  • 15
1
vote
0 answers

GraphQL Ruby: is there way to detect n + 1 issue?

I'm trying to detect n + 1 issue(s) in a Ruby on Rails + GraphQL API created by my predesessor. Firstly, I tried famous bullet gem which logs warning when n + 1 issue occurs. However, it doesn't log GraphQL query body. It only logs HTTP method and…
Nullable Yogurt
  • 207
  • 2
  • 7
1
vote
1 answer

Graphql-ruby Bulding Mutation/query Without the need of user authentication

Hey I have a graphql mutation which needs to be implemented before user logs in. Till now I have been using graphql endpoints only after User is fully authenticated. Since graphql controller inherits application controller which implements a…
JIGME
  • 23
  • 4
1
vote
2 answers

Graphql-Ruby: Creating interfaces that objects can inherit fields from

module Types::ProgramType include Types::BaseInterface description "Objects which inherit from Program" graphql_name "Program" orphan_types Types::SomeProgramType, Types::AnotherProgramType,…
KSC
  • 78
  • 10
1
vote
3 answers

How to modify context for child fields in graphql-ruby?

I have query like this: query { organizations { id name itemA { fieldA fieldB } } } returns "data": { "organizations": [ { "id": 123, "name": "first org", "itemA": { "fieldA": "some…
Andrii H
  • 21
  • 4
1
vote
2 answers

For some reason the "new" method is protected on a subclass of Graphql-ruby's BaseConnection

The error I'm getting is: NoMethodError Exception: protected method `new' called for Connections::MySubclassConnection:Class I've implemented a BaseConnection < GraphQL::Types::Relay::BaseConnection in base_connection.rb and then created a subclass…
1
vote
2 answers

What's the best practice to achieve dependency injection with ruby-graphql?

I want to use dependency injection with graphql-ruby. I.e. module CustomerCredits module Types class QueryType < GraphQL::Schema::Object description 'The query root of this schema' field :filter_users, [Types::UserType], null:…
wuarmin
  • 3,274
  • 3
  • 18
  • 31
1
vote
1 answer

How to add a default value to sort: in query_type.rb

Existing code in query_type.rb: def flags(program_id:, filter: {}, sort: {}) program = Program.find(program_id) context[:auth].set_current_parent_program_id(program.id) flags = Report.joins(:participant).where(registrants: {…
nm12
  • 81
  • 7
1
vote
1 answer

How to invoke custom method in GraphQL::Schema

I am trying to add a check in GraphQL::Schema. I want to call a method where I have defined my schema. One Way is to call the method in GraphqlController. But, I am not able to get the arguments that are sent in the mutation/query only the query…
aniket
  • 95
  • 5
  • 12