graphql-crystal
graphql-crystal copied to clipboard
schema init
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)
- It will search files in directories
- It will filter files by included GraphQL::ObjectType
- It will use method to_graphql
- it will create schema from converted strings
::GraphQL::Schema.from_paths(['path1', 'path2'])