{"action":"created","comment":{"url":"https://api.github.com/repos/rmosolgo/graphql-ruby/pulls/comments/168706379","pull_request_review_id":97118209,"id":168706379,"diff_hunk":"@@ -0,0 +1,205 @@\n+---\n+layout: guide\n+search: true\n+section: Schema\n+title: Definition\n+desc: Defining your schema\n+class_based_api: true\n+---\n+\n+A GraphQL system is called a _schema_. The schema contains all the types and fields in the system. The schema executes queries and publishes an {% internal_link \"introspection system\",\"/schema/introspection\" %}.\n+\n+Your GraphQL schema is a class that extends {{ \"GraphQL::Schema\" | api_doc }}, for example:\n+\n+```ruby\n+class MyAppSchema < GraphQL::Schema\n+  max_complexity 400\n+  query Types::Query\n+  use GraphQL::Batch\n+\n+  # Define hooks as class methods:\n+  def self.resolve_type(type, obj, ctx)\n+    # ...\n+  end\n+\n+  def self.object_from_id(node_id, ctx)\n+    # ...\n+  end\n+\n+  def self.id_from_object(object, type, ctx)\n+    # ...\n+  end\n+end\n+```\n+\n+There are lots of schema configuration options:\n+\n+- [root objects, introspection and orphan types](#root-objects-introspection-and-orphan-types)\n+- [object identification hooks](#object-identification-hooks)\n+- [execution configuration](#execution-configuration)\n+- [context class](#context-class)\n+- [default limits](#default-limits)\n+- [plugins](#plugins)\n+\n+## Root Objects, Introspection and Orphan Types\n+\n+A GraphQL schema is a web of interconnected types, and it has a few starting points for discovering the elements of that web:\n+\n+__Root types__ (`query`, `mutation`, and `subscription`) are the [entry points for queries to the system](http://graphql.org/learn/schema/#the-query-and-mutation-types). Each one is an object type which can be connected to the schema by a method with the same name:\n+\n+```ruby\n+class MySchema < GraphQL::Schema\n+  # Required:\n+  query Types::Query\n+  # Optional:\n+  mutation Types::Mutation\n+  subscription Types::Subscription\n+end\n+```\n+\n+__Introspection__ is a built-in part of the schema. Every schema has a default introspection system, but you can {% internal_link \"customize it\",\"/schema/introspection\" %} and hook it up with `introspection`:\n+\n+```ruby\n+class MySchema < GraphQL::Schema\n+  introspection CustomIntrospection\n+end\n+```\n+\n+__Orphan Types__ are types which should be in the schema, but can't be discovered by traversing the types and fields from `query`, `mutation` or `subscription`. This has one very specific use case, see {% internal_link \"Orphan Types\", \"/type_definitions/interfaces#orphan-types\" %}.\n+\n+```ruby\n+class MySchema < GraphQL::Schema\n+  orphan_types [Types::Comment, ...]\n+end\n+```\n+\n+## Object Identification Hooks\n+\n+A GraphQL schema needs a handful of hooks for finding and disambiguating objects while queries are executed.\n+\n+__`resolve_type`__ is used when a specific object's corresponding GraphQL type must be determined. This happens for fields that return interface or union types. The class method `def self.resolve_type` is used:\n+\n+```ruby\n+class MySchema < GraphQL::Schema\n+  def self.resolve_type(abstract_type, object, context)\n+    # Disambiguate `object`, from among `abstract_type`'s members\n+    # (`abstract_type` is an interface or union type.)\n+  end\n+end\n+```\n+\n+__`object_from_id`__ is used by Relay's `node(id: ID!): Node` field. It receives a unique ID and must return the object for that ID, or `nil` if the object isn't found (or if the should be hidden from the current user).\n+\n+```ruby\n+class MySchema < GraphQL::Schema\n+  def self.object_from_id(unique_id, context)\n+    # Find and return the object for `unique_id`\n+    # or `nil`\n+  end\n+end\n+```\n+\n+__`id_from_object`__ is used to implement Relay's `Node.id` field. It should return a unique ID for the given object. This ID will later be sent to `object_from_id` to refetch the object.\n+\n+```ruby\n+class MySchema < GraphQL::Schema\n+  def self.object_from_id(object, type, context)","path":"guides/schema/definition.md","position":106,"original_position":106,"commit_id":"d42da1180d491aeab4c3a9bbb0ebc8d322f22afb","original_commit_id":"d42da1180d491aeab4c3a9bbb0ebc8d322f22afb","user":{"login":"ximus","id":48771,"avatar_url":"https://avatars1.githubusercontent.com/u/48771?v=4","gravatar_id":"","url":"https://api.github.com/users/ximus","html_url":"https://github.com/ximus","followers_url":"https://api.github.com/users/ximus/followers","following_url":"https://api.github.com/users/ximus/following{/other_user}","gists_url":"https://api.github.com/users/ximus/gists{/gist_id}","starred_url":"https://api.github.com/users/ximus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ximus/subscriptions","organizations_url":"https://api.github.com/users/ximus/orgs","repos_url":"https://api.github.com/users/ximus/repos","events_url":"https://api.github.com/users/ximus/events{/privacy}","received_events_url":"https://api.github.com/users/ximus/received_events","type":"User","site_admin":false},"body":"`object_from_id` => `id_from_object`","created_at":"2018-02-16T09:24:07Z","updated_at":"2018-02-16T09:24:08Z","html_url":"https://github.com/rmosolgo/graphql-ruby/pull/1274#discussion_r168706379","pull_request_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/pulls/1274","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/rmosolgo/graphql-ruby/pulls/comments/168706379"},"html":{"href":"https://github.com/rmosolgo/graphql-ruby/pull/1274#discussion_r168706379"},"pull_request":{"href":"https://api.github.com/repos/rmosolgo/graphql-ruby/pulls/1274"}}},"pull_request":{"url":"https://api.github.com/repos/rmosolgo/graphql-ruby/pulls/1274","id":168685890,"html_url":"https://github.com/rmosolgo/graphql-ruby/pull/1274","diff_url":"https://github.com/rmosolgo/graphql-ruby/pull/1274.diff","patch_url":"https://github.com/rmosolgo/graphql-ruby/pull/1274.patch","issue_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/1274","number":1274,"state":"open","locked":false,"title":"[1.8] Docs","user":{"login":"rmosolgo","id":2231765,"avatar_url":"https://avatars3.githubusercontent.com/u/2231765?v=4","gravatar_id":"","url":"https://api.github.com/users/rmosolgo","html_url":"https://github.com/rmosolgo","followers_url":"https://api.github.com/users/rmosolgo/followers","following_url":"https://api.github.com/users/rmosolgo/following{/other_user}","gists_url":"https://api.github.com/users/rmosolgo/gists{/gist_id}","starred_url":"https://api.github.com/users/rmosolgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmosolgo/subscriptions","organizations_url":"https://api.github.com/users/rmosolgo/orgs","repos_url":"https://api.github.com/users/rmosolgo/repos","events_url":"https://api.github.com/users/rmosolgo/events{/privacy}","received_events_url":"https://api.github.com/users/rmosolgo/received_events","type":"User","site_admin":true},"body":"I want to release 1.8 with some docs about the new APIs: \r\n\r\n- Types: \r\n  - [x] Objects, Fields, Arguments  \r\n  - [x] Scalars \r\n  - [x] Enums & Enum Values \r\n  - [x] Input Objects \r\n  - [x] Interfaces \r\n  - [x] Unions \r\n  - [x] Lists \r\n  - [x] Non-Null Types \r\n- [x] Extending the type system \r\n- [x] Introspection \r\n- [x] Context \r\n- [x] Schema class \r\n- [x] Add a header flag about the class-based api \r\n- Any others?","created_at":"2018-02-12T20:56:54Z","updated_at":"2018-02-16T09:24:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"78f3467cfdb7ffef1b80bdc7285d5c52728a824d","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/pulls/1274/commits","review_comments_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/pulls/1274/comments","review_comment_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/1274/comments","statuses_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/statuses/d42da1180d491aeab4c3a9bbb0ebc8d322f22afb","head":{"label":"rmosolgo:1.8-docs","ref":"1.8-docs","sha":"d42da1180d491aeab4c3a9bbb0ebc8d322f22afb","user":{"login":"rmosolgo","id":2231765,"avatar_url":"https://avatars3.githubusercontent.com/u/2231765?v=4","gravatar_id":"","url":"https://api.github.com/users/rmosolgo","html_url":"https://github.com/rmosolgo","followers_url":"https://api.github.com/users/rmosolgo/followers","following_url":"https://api.github.com/users/rmosolgo/following{/other_user}","gists_url":"https://api.github.com/users/rmosolgo/gists{/gist_id}","starred_url":"https://api.github.com/users/rmosolgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmosolgo/subscriptions","organizations_url":"https://api.github.com/users/rmosolgo/orgs","repos_url":"https://api.github.com/users/rmosolgo/repos","events_url":"https://api.github.com/users/rmosolgo/events{/privacy}","received_events_url":"https://api.github.com/users/rmosolgo/received_events","type":"User","site_admin":true},"repo":{"id":30337170,"name":"graphql-ruby","full_name":"rmosolgo/graphql-ruby","owner":{"login":"rmosolgo","id":2231765,"avatar_url":"https://avatars3.githubusercontent.com/u/2231765?v=4","gravatar_id":"","url":"https://api.github.com/users/rmosolgo","html_url":"https://github.com/rmosolgo","followers_url":"https://api.github.com/users/rmosolgo/followers","following_url":"https://api.github.com/users/rmosolgo/following{/other_user}","gists_url":"https://api.github.com/users/rmosolgo/gists{/gist_id}","starred_url":"https://api.github.com/users/rmosolgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmosolgo/subscriptions","organizations_url":"https://api.github.com/users/rmosolgo/orgs","repos_url":"https://api.github.com/users/rmosolgo/repos","events_url":"https://api.github.com/users/rmosolgo/events{/privacy}","received_events_url":"https://api.github.com/users/rmosolgo/received_events","type":"User","site_admin":true},"private":false,"html_url":"https://github.com/rmosolgo/graphql-ruby","description":"Ruby implementation of GraphQL ","fork":false,"url":"https://api.github.com/repos/rmosolgo/graphql-ruby","forks_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/forks","keys_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/teams","hooks_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/hooks","issue_events_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/events{/number}","events_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/events","assignees_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/assignees{/user}","branches_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/branches{/branch}","tags_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/tags","blobs_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/git/refs{/sha}","trees_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/statuses/{sha}","languages_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/languages","stargazers_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/stargazers","contributors_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/contributors","subscribers_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/subscribers","subscription_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/subscription","commits_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/commits{/sha}","git_commits_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/git/commits{/sha}","comments_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/comments{/number}","issue_comment_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/comments{/number}","contents_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/contents/{+path}","compare_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/merges","archive_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/downloads","issues_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues{/number}","pulls_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/pulls{/number}","milestones_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/milestones{/number}","notifications_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/labels{/name}","releases_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/releases{/id}","deployments_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/deployments","created_at":"2015-02-05T04:11:22Z","updated_at":"2018-02-15T23:02:49Z","pushed_at":"2018-02-15T19:44:39Z","git_url":"git://github.com/rmosolgo/graphql-ruby.git","ssh_url":"git@github.com:rmosolgo/graphql-ruby.git","clone_url":"https://github.com/rmosolgo/graphql-ruby.git","svn_url":"https://github.com/rmosolgo/graphql-ruby","homepage":"http://graphql-ruby.org","size":10654,"stargazers_count":2497,"watchers_count":2497,"language":"Ruby","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":319,"mirror_url":null,"archived":false,"open_issues_count":109,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":319,"open_issues":109,"watchers":2497,"default_branch":"master"}},"base":{"label":"rmosolgo:1.8-dev","ref":"1.8-dev","sha":"ec2003a986d13a5050797d6afb88567be9850bac","user":{"login":"rmosolgo","id":2231765,"avatar_url":"https://avatars3.githubusercontent.com/u/2231765?v=4","gravatar_id":"","url":"https://api.github.com/users/rmosolgo","html_url":"https://github.com/rmosolgo","followers_url":"https://api.github.com/users/rmosolgo/followers","following_url":"https://api.github.com/users/rmosolgo/following{/other_user}","gists_url":"https://api.github.com/users/rmosolgo/gists{/gist_id}","starred_url":"https://api.github.com/users/rmosolgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmosolgo/subscriptions","organizations_url":"https://api.github.com/users/rmosolgo/orgs","repos_url":"https://api.github.com/users/rmosolgo/repos","events_url":"https://api.github.com/users/rmosolgo/events{/privacy}","received_events_url":"https://api.github.com/users/rmosolgo/received_events","type":"User","site_admin":true},"repo":{"id":30337170,"name":"graphql-ruby","full_name":"rmosolgo/graphql-ruby","owner":{"login":"rmosolgo","id":2231765,"avatar_url":"https://avatars3.githubusercontent.com/u/2231765?v=4","gravatar_id":"","url":"https://api.github.com/users/rmosolgo","html_url":"https://github.com/rmosolgo","followers_url":"https://api.github.com/users/rmosolgo/followers","following_url":"https://api.github.com/users/rmosolgo/following{/other_user}","gists_url":"https://api.github.com/users/rmosolgo/gists{/gist_id}","starred_url":"https://api.github.com/users/rmosolgo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmosolgo/subscriptions","organizations_url":"https://api.github.com/users/rmosolgo/orgs","repos_url":"https://api.github.com/users/rmosolgo/repos","events_url":"https://api.github.com/users/rmosolgo/events{/privacy}","received_events_url":"https://api.github.com/users/rmosolgo/received_events","type":"User","site_admin":true},"private":false,"html_url":"https://github.com/rmosolgo/graphql-ruby","description":"Ruby implementation of GraphQL ","fork":false,"url":"https://api.github.com/repos/rmosolgo/graphql-ruby","forks_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/forks","keys_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/teams","hooks_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/hooks","issue_events_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/events{/number}","events_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/events","assignees_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/assignees{/user}","branches_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/branches{/branch}","tags_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/tags","blobs_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/git/refs{/sha}","trees_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/statuses/{sha}","languages_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/languages","stargazers_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/stargazers","contributors_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/contributors","subscribers_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/subscribers","subscription_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/subscription","commits_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/commits{/sha}","git_commits_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/git/commits{/sha}","comments_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/comments{/number}","issue_comment_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/comments{/number}","contents_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/contents/{+path}","compare_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/merges","archive_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/downloads","issues_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues{/number}","pulls_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/pulls{/number}","milestones_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/milestones{/number}","notifications_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/labels{/name}","releases_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/releases{/id}","deployments_url":"https://api.github.com/repos/rmosolgo/graphql-ruby/deployments","created_at":"2015-02-05T04:11:22Z","updated_at":"2018-02-15T23:02:49Z","pushed_at":"2018-02-15T19:44:39Z","git_url":"git://github.com/rmosolgo/graphql-ruby.git","ssh_url":"git@github.com:rmosolgo/graphql-ruby.git","clone_url":"https://github.com/rmosolgo/graphql-ruby.git","svn_url":"https://github.com/rmosolgo/graphql-ruby","homepage":"http://graphql-ruby.org","size":10654,"stargazers_count":2497,"watchers_count":2497,"language":"Ruby","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":319,"mirror_url":null,"archived":false,"open_issues_count":109,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":319,"open_issues":109,"watchers":2497,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rmosolgo/graphql-ruby/pulls/1274"},"html":{"href":"https://github.com/rmosolgo/graphql-ruby/pull/1274"},"issue":{"href":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/1274"},"comments":{"href":"https://api.github.com/repos/rmosolgo/graphql-ruby/issues/1274/comments"},"review_comments":{"href":"https://api.github.com/repos/rmosolgo/graphql-ruby/pulls/1274/comments"},"review_comment":{"href":"https://api.github.com/repos/rmosolgo/graphql-ruby/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rmosolgo/graphql-ruby/pulls/1274/commits"},"statuses":{"href":"https://api.github.com/repos/rmosolgo/graphql-ruby/statuses/d42da1180d491aeab4c3a9bbb0ebc8d322f22afb"}},"author_association":"OWNER"}}
{"actor":{"display_login":"ximus"}}