Skip to content

schema init  #35

@ExplosiveGM

Description

@ExplosiveGM

Can we declare schema in one place?
Your kemal example has schema_string and type declaration:

  # A User
  type User implements UniqueId {
    # users first name
    firstName: String!
    # users last name
    lastName: String!
    # full name string for the user
    fullName: String! @deprecated(reason: "no need to construct this serverside..")
    # users role
    role: UserRole!
    # posts published
    # by this user
    posts: [Post!]
    # total number of posts
    # published by this user
    postsCount: Int!
  }
class User
  include ::GraphQL::ObjectType
  include UniqueId
  field :firstName { first_name }
  field :lastName { last_name }
  field :fullName { "#{@first_name} #{@last_name}" }
  field :posts { POSTS.select &.author.==(self)}
  field :postsCount { POSTS.select( &.author.==(self) ).size }
  field :role
end

rmosolgo/graphql-ruby uses some LateBoundType but it is magic.
Can we add to schema.cr some simple method like:
from_paths(paths : Array)

  1. It will search files in directories
  2. It will filter files by included GraphQL::ObjectType
  3. It will use method to_graphql
  4. it will create schema from converted strings

::GraphQL::Schema.from_paths(['path1', 'path2'])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions