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
0
votes
0 answers

Problem with current_user in GrapghqlController

I'm trying to assign a value to current_user in GraphqlController but it's not working. this is my code in graphql_controller.rb class GraphqlController < ApplicationController # If accessing from outside this domain, nullify the session # This…
0
votes
0 answers

How can I share code between multiple graphql ruby mutations?

I'd like to write a method that is used by multiple mutations, similar to defining a method in a controller that is shared amongst multiple actions. How can I do this?
John Bachir
  • 22,495
  • 29
  • 154
  • 227
0
votes
1 answer

Rails and graphql casing convention

I am starting to dive into graphql, building my first API with Rails. I have tons of questions regarding standards and conventions. For example, I noticed the gem graphql by default requires the fields to be passed in CammelCase, when actually when…
Leticia Esperon
  • 2,499
  • 1
  • 18
  • 40
0
votes
1 answer

Run function before any query in GraphQL ruby

I want to run a function before any query I run on GraphQL. I want to control some condition and throw a GraphQL:: ExecutionError in case it catches the error. I know there is a base query that runs before any query but it is needed to check if a…
john bowlee
  • 125
  • 1
  • 11
0
votes
0 answers

How to write a GraphQL type definition for a class whose name ends on Type

I'm trying to define GraphQL type definitions. As far as I understand a class has to have a type definition named like the class, plus an appended Type. I have a class called CourseType, which leads me to this type…
Linus
  • 4,643
  • 8
  • 49
  • 74
0
votes
1 answer

Redefine custom subscriptions on GraphQL Schema

We are facing an issue where we would like to replace a custom subscriptions object on the GraphQL Schema on the fly (mostly for testing). We currently have the following schema: class MySchema < GraphQL::Schema query CustomQueryType mutation…
hschne
  • 704
  • 5
  • 21
0
votes
1 answer

Graphql-Ruby Mapping using Active Record

I am completely new to using Rails, I'm trying to create a basic crud application using ruby-graphql to do a simple find query with active record to a sqlite3 database. I set up a user type class UserType < Types::BaseObject description "A…
0
votes
1 answer

How can I get graphql-ruby to use joins when accessing subfields?

I have a model like this class Foo has_many :bars end and a query like this query foos( $offset: Int $sort_by: String $should_paginate: Boolean ) { foos( offset: $offset sort_by: $sort_by should_paginate: $should_paginate )…
John Bachir
  • 22,495
  • 29
  • 154
  • 227
0
votes
1 answer

Field has a strange behavior if I don't use method:

I am using graphql-ruby gem v 1.9.6 with the class-version base. I am using 2 models. See below. model 1 : class User < ApplicationRecord include EnsureUUID has_secure_password has_one :freelancer, dependent: :destroy .... model 2 : class…
0
votes
1 answer

Proper way to DRY up multiple lambdas in a GraphQL mutation

I'm trying to take a bunch of lambdas that do the same thing and DRY them up by breaking it out in to a method. The code in question is in a module / class and I've forgotten the correct way to do this :/ The docs show an example like this using a…
0
votes
1 answer

Connections breaks includes

I have a following setup: class Product < ApplicationRecord has_many :variants end class Variant < ApplicationRecord belongs_to :product end Types::QueryType = GraphQL::ObjectType.define do connection :products,…
mbajur
  • 4,406
  • 5
  • 49
  • 79
0
votes
1 answer

Process connection_type after resolved

I use graphql gem 1.8.11. My UserType has notifications connection field and if it is queried I'd like to perform some operation (read! in example below). Example below performs the operation for all of association field. Even if notifications field…
yskkin
  • 854
  • 7
  • 24
0
votes
1 answer

dry-rb_autoinject and GraphQL

I am trying to make a GraphQL API, but also implement dependency injection through dry-rb_autoinject. I managed to do this via controller and context. Here's my test QueryType. Types::QueryType = GraphQL::ObjectType.define do name "Query" # Add…
alt-ja
  • 144
  • 1
  • 11
0
votes
1 answer

GraphQL Ruby Subscription Executing Initial Query

With GraphQL Ruby it possible to have a GraphQL subscription also return resolves when subscribing? For example: module Types class SampleType < GraphQL::Schema::Object field :greeting, String, null: false def greeting 'Howdy!' …
Kevin Sylvestre
  • 37,288
  • 33
  • 152
  • 232
0
votes
1 answer

How to get graphql-ruby to serialize calculated/projected/derived/non-database columns from a query in an ActiveRecord model

Using result = Model.select(Model.table_name + '.*') result = result.select(47 AS new_column) result = result.where(...).order(...).limit(...) # etc. result.to_a # gives an array of Model instances I need to access the new_column value as…
1 2 3
9
10