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
33
votes
2 answers

Result of a delete mutation?

What should be the result of a delete mutation in Graphql? I'm using the graphql-ruby gem. Here's an example of my mutation, but I'm just not sure what I should be returning as the response. Mutations::Brands::Delete =…
Jimmy Baker
  • 3,215
  • 1
  • 24
  • 26
22
votes
3 answers

Graphql mutations without arguments

Generally a query is when you fetch data and mutation is when you manipulate data. But how would I implement a mutation without any arguments? In my particular case I have delete and create 2fa token endpoints. Both the delete and create token have…
dan-klasson
  • 13,734
  • 14
  • 63
  • 101
18
votes
4 answers

graphql-ruby, Date or Datetime type

I'm not the only one who doesn't know how to use Datetime types with GraphQL-Ruby: https://github.com/rmosolgo/graphql-ruby-demo/issues/27, as you can see there are 18 people like me. How can I use Datetime to some fields like…
user4412054
7
votes
0 answers

GraphQL Ruby 'Duplicate type definition found' error

I'm trying to update my mutation with variables and receive such error: Duplicate type definition found for name 'SignInInput' at 'Input field SignInInput.signInInput' My mutation code: module Mutations class SignIn < BaseMutation …
Nadiya
  • 1,421
  • 4
  • 19
  • 34
6
votes
3 answers

Authorization on a field in graphql-ruby

From this guide I don't understand how we can add authorization on a field in graphql-ruby. I understand how we can deny access to an entire object but I don't see how we can prevent access to just a field of an object. In my usecase, I want to…
Such
  • 910
  • 1
  • 9
  • 20
6
votes
1 answer

How can I have one field updating/changing another one?

I'd like to get fields resolved by another field. I have a list generated according to some arguments and would like to update the total field My approach is probably incorrect. Obviously, I'm trying to avoid re-running the same database query and…
Jeremy
  • 942
  • 1
  • 10
  • 28
6
votes
0 answers

GraphQL - Allow only certain values for Input Types

I am using the [graphql][1] gem to build out a GraphQL API. When defining inputs for example -- Inputs::BranchInput = GraphQL::InputObjectType.define do name 'BranchInput' argument :scope, types.String end The argument…
Michael Victor
  • 861
  • 2
  • 18
  • 42
5
votes
1 answer

Defining input types in graphql-ruby

I'm trying to implement an input type for filters with graphql-ruby and rails. Base input type looks like: module Types class BaseInputObject < GraphQL::Schema::InputObject end end My own input type looks like: module Types class…
Dor-Ron
  • 1,787
  • 3
  • 15
  • 27
5
votes
1 answer

Generate a schema.json with graphql-ruby

How can I generate a schema.json like the code in the links? https://github.com/exAspArk/graphql-on-rails/blob/master/schema.json https://github.com/Shopify/graphql-js-client/blob/master/schema.json
K-Sato
  • 400
  • 7
  • 26
5
votes
1 answer

How to pass :current_user in Graphql resolver

I have QueryType Types::QueryType = GraphQL::ObjectType.define do name 'Query' field :allProjects, function: Resolvers::Projects end And Resolver like this require 'search_object/plugin/graphql' module Resolvers class Projects include…
suyesh
  • 530
  • 7
  • 23
5
votes
3 answers

How to test a GraphQL schema with graphql-ruby?

My goal is to test the types of my GraphQL schema in ruby, I'm using the graphql-ruby gem. I couldn't find any best practice for this, so I'm wondering what's the best way to test the fields and types of a Schema. The gem recommends against testing…
Carlos Martinez
  • 4,350
  • 5
  • 32
  • 62
5
votes
1 answer

Difference between field and connection in Graphql ruby?

I am new to Graphql. For a simple use case, Let's say i have simple model, class Post < ActiveRecord::Base has_many :comments end Below is the code in my graphql query_type.rb PostType = GraphQL::ObjectType.define do #field :comments,…
Deepak Kumar Padhy
  • 4,128
  • 6
  • 43
  • 79
4
votes
1 answer

Graphql-ruby how to define a hash as type

Is there a possibility to define a Hash as Type field in graphql-ruby schema? In my data structure there is a multi language String type, which consist out of the language code as key and a corresponding text. At the Moment there are 2 languages…
4
votes
1 answer

is there a way to group queries in graphQL?

I'm trying to group graphQL queries to have a more organized response. I want to make a query for allEmployees and get back something in the following format GraphQL Query { Employees:allEmployees{ id firstName lastName …
SegFaultDev
  • 455
  • 1
  • 7
  • 24
4
votes
1 answer

Duplicate type definition found for name 'Connection' in graphql pagination

I have used connection helper for implementing pagination in graphql apis.I want to implement connection more than once for same model but it gives me duplicate type error. Can anyone suggest solution for supporting pagination for more than one apis…
darshi kothari
  • 642
  • 1
  • 5
  • 12
1
2 3
9 10