You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using graphql-ruby 1.7.10 in a Rails 4.2.7.1 project, and I'm trying to see if it's possible to use a .gql file to define my schema, rather than using the supplied DSL. Based on the tests in build_from_definition_spec, I decided to try using GraphQL::Schema.from_definition.
I replaced my previous (working) app_schema.rb file:
AppSchema = GraphQL::Schema.define do
mutation(Types::MutationType)
query(Types::QueryType)
end
After a fair amount of time with my good friend pry, and comparing my code to that in build_from_description_spec.rb, my suspicion is that I need some kind of root resolver, but as I'm new to both this gem and GraphQL in general I'm not sure if I'm on the right track.
My schema:
type Award {
closes_at: Time!
core_value_question: String
description: String
# A count of the number of people who are in the groups selected as eligible
# nominators. Before the Award has ended, this is expensive to compute. After
# the award has ended, this number is stored and no longer computationally expensive.
eligible_nominator_count: Int
eligible_nominee_count: Int
has_nomination_limit: Boolean!
nomination_limit: Int
nominator_eligibility_groups: [String]
nominee_eligibility_groups: [String]
nominee_question: String!
opens_at: Time!
rationale_question: String!
send_invitations_on_open: Boolean!
send_reminders_before_close: Boolean!
skills_question: String
status: AwardStatusEnumType!
title: String!
}
# An Award can be in one of four states, depending on its open and close dates and whether a winner has been selected
enum AwardStatusEnumType {
# Not accepting nominations; a winner has been selected
awarded
# No longer accepting nominations; a winner has not been selected
ended
# Accepting nominations
live
# Not yet accepting nominations
scheduled
}
type Company {
name: String!
subdomain: String!
}
type Mutation {
# An example field added by the generator
testField: String
}
type Query {
# Fetch an Award by ID
award(id: String!): Award
# Finds a Company by subdomain
company(subdomain: String!): Company
# Fetch the currently logged-in user
me: User
# Find a user by email address
user(email: String!): User
}
scalar Time
type User {
email: String!
first_name: String
last_name: String
}
The text was updated successfully, but these errors were encountered:
It was added to experiment with different workflows, I heard on Slack that Vox Media is using it in a pretty nice way, similar to the "Resolving with a single function" documented here:
I'm using graphql-ruby 1.7.10 in a Rails 4.2.7.1 project, and I'm trying to see if it's possible to use a
.gql
file to define my schema, rather than using the supplied DSL. Based on the tests in build_from_definition_spec, I decided to try usingGraphQL::Schema.from_definition
.I replaced my previous (working)
app_schema.rb
file:with:
where
GRAPHQL_SCHEMA_FILE
names a file containing my schema in what #727 calls "IDL" format (included below).Having done so, I expected that I would be able to run queries. Instead, the following exception is raised:
After a fair amount of time with my good friend
pry
, and comparing my code to that inbuild_from_description_spec.rb
, my suspicion is that I need some kind of root resolver, but as I'm new to both this gem and GraphQL in general I'm not sure if I'm on the right track.My schema:
The text was updated successfully, but these errors were encountered: