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
3
votes
1 answer

How do I raise two errors with graphql-ruby?

I'm using the graphql-ruby gem and I have a mutation that updates a record. This is all working, but now I want to include the phony_rails gem to validate phone number. The problem As a dev with more FE experience, I'm not great with rails or ruby…
nyphur
  • 2,404
  • 2
  • 24
  • 48
3
votes
1 answer

Grouping in GraphQL query

I am new to GraphQl and learning it. Currently I have single database Table - student_courses as shown below: student_id| student_name | course_code | course_name 1 ABC S-101 DataStructures 1 ABC …
skool99
  • 780
  • 1
  • 16
  • 35
3
votes
1 answer

Dealing with GraphQL Enum values in business code

I have a GraphQL enum like: class MediaFilterType < Types::BaseEnum value "TWITTER", value: :twitter value "FACEBOOK", value: :facebook value "YOUTUBE", value: :youtube end And a field that receives an array of this type or nil. Actually when…
Tiago Farias
  • 3,397
  • 1
  • 27
  • 30
3
votes
1 answer

Ruby graphql How to define object type which is not Active Record?

I want to create a MentionType which is not in ActiveRecord. And when query SummaryCommentType I want to return MentionType with it. But I dont know how to. I am completely new for graphql. Sorry for my english. Here is my code module Types class…
freeman
  • 92
  • 11
3
votes
0 answers

change value of a type's field depending on resolver argument in graphql-ruby

I'm trying to calculate a field's value of a Type, but I have to take in account the argument passed to my resolver by the user (query). A dummy example: Let's say I have two models in my rails app : Dog and Price (a Dog has_many prices, depending…
Alexis Delahaye
  • 644
  • 5
  • 18
3
votes
2 answers

How to return a Union type from a GraphQL Mutation

I want to use this pattern for returning validation failures from the GraphQL Ruby: https://medium.com/@sachee/200-ok-error-handling-in-graphql-7ec869aec9bc From my mutation I'd like to be able to return a payload that is a union like this: …
james2m
  • 1,562
  • 12
  • 15
3
votes
0 answers

How do I accept field arguments for a nested query in Graphql Ruby?

I'm getting this error in GraphQl (Apollo JS/ Graphql Ruby): Error Error: GraphQL error: Field 'pagination' doesn't accept argument 'pagination' GraphQL error: Variable $pagination is declared by Clients but not used. Reload the page and try…
Taysky
  • 4,331
  • 2
  • 20
  • 28
3
votes
1 answer

Undefined method `deprecation_reason' for Resolvers

I'm defining a resolver for some fields, using the graphql gem for ruby. This is the Resolver definition: module Resolvers class Events < BaseResolver type [Types::EventType], null: true argument :input, Types::EventInput, required:…
3
votes
1 answer

Use case of GraphQL Subscriptions

I am learning about implementing GraphQL API in Rails app using graphql-ruby gem. I am not clear about the use-case of GraphQL Subscriptions. I don't clearly understand the difference between GraphQL Subscriptions and ActionCable. Let's say I have a…
3
votes
1 answer

Why does graphql-ruby function definition work via kwarg, but not via the function method in a block?

Where class FindRecord < GraphQL::Function ... argument :id, !types.ID ... end this variation of a field definition within a GraphQL::ObjectType.define block works without error: field 'd1', DirectoryType, function:…
Mori
  • 27,279
  • 10
  • 68
  • 73
3
votes
1 answer

How to handle a field that could return one of several scalar types in graphql

In graphql (using the excellent graphql-ruby gem), I'm trying to return an object with a field that can equal either a Boolean, Integer, or String. My initial thought was to return a union of Boolean, Integer, or String, but graphql-ruby informed me…
John
  • 9,249
  • 5
  • 44
  • 76
3
votes
1 answer

VueJS, Apollo, Rails - Can't verify CSRF token authenticity

Here is my setup const token = $('meta[name="csrf-token"]').attr('content'); const authLink = setContext((_, { headers }) => { // return the headers to the context so httpLink can read them return { headers: { ...headers, …
James Klein
  • 612
  • 4
  • 15
3
votes
3 answers

graphql-ruby. Use (not Relay) mutations DRY. With or without GraphQL::Function?

I'M NOT USING RELAY. I have read some tutorials. Many use this way for mutations: app/graphql/graphql_tutorial_schema.rb GraphqlTutorialSchema = GraphQL::Schema.define do query(Types::QueryType) …
user4412054
3
votes
2 answers

includes/eager load associated models with graphql-ruby

I've been searching for examples on how to translate a traditional ActiveRecod .includes for associated models, while using graphQL-ruby, and haven't found any. As a use case, let's say we have the following models: User has_many…
frostini
  • 175
  • 10
1
2
3
9 10