{"action":"created","comment":{"url":"https://api.github.com/repos/dgraph-io/dgraph/pulls/comments/75623334","id":75623334,"diff_hunk":"@@ -0,0 +1,175 @@\n+/*\n+ * Copyright 2015 DGraph Labs, Inc.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * \t\thttp://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+package types\n+\n+import (\n+\t\"fmt\"\n+)\n+\n+//TODO(akhil): make underlying interfaces for stricter definitions of types\n+\n+\n+/**\n+ * GraphQLScalar type defines concrete structure for scalar types to use.\n+ * Almost all scalar types can also act as input types.\n+ * Scalars (along with Enums) form leaf nodes of request or input values to arguements. \n+ */\n+type GraphQLScalar struct {\n+\tName \t\t\tstring\t\t\t//name of scalar type\n+\tDescription \tstring\t\t\t//short description, could be used for documentation in GraphiQL\n+\tConfig \t\t\tScalarConfig\t//config struct to construct a custom scalar\n+\tErr\t\t\t\terror\t\t\t//error object\n+}\n+\n+//SerializeFunc is a function type that serializes GraphQL Scalar types.\n+type SerializeFunc func(input interface{}) interface{}\n+\n+\n+//ParseValueFunc is a function type that parses the value of GraphQL Scalar types.\n+type ParseValueFunc func(input interface{}) interface{}\n+\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n+\n+//ParseLiteralFunc is a function type that parses literal value of GraphQL Scalar types.\n+type ParseLiteralFunc func(input interface{}) interface{}\n+\n+\n+//ScalarConfig to pass config params to scalar type constructor function.\n+type ScalarConfig struct {\n+\tName\t\t\tstring\t\t\t\t\n+\tDescription\t\tstring\t\t\t\t\n+\tSerialize\t\tSerializeFunc\t\t\n+\t// ParseValue\t\tParseValueFunc\n+\t// ParseLiteral\tParseLiteralFunc\n+}\n+\n+/**\n+ * MakeScalarType declares a custom scalar type using the input configuration.\n+ * Custom scalar could directly be defined as well, but this function gives us flexibility\n+ * to do validations and catch errors. \n+ * Basic scalar types supported by GraphQL are:\n+ * \t\t- Int\n+ * \t\t- Float\n+ * \t\t- String\n+ * \t\t- Boolean\n+ * \t\t- ID \n+ */\n+func MakeScalarType(sc *ScalarConfig) (*GraphQLScalar) {\n+\tscalarType := &GraphQLScalar{}\n+\n+\t//check if all essential config is present\n+\tif sc.Name != \"\" && validName(sc.Name){\n+\t\tscalarType.Name = sc.Name\n+\t} else {\n+\t\tscalarType.Err = makeTypeError(\"Type must be named.\")\n+\t\treturn scalarType\n+\t}\n+\n+\tscalarType.Description = sc.Description\n+\n+\tif sc.Serialize == nil {\n+\t\tscalarType.Err = makeTypeError(\n+\t\t\t\tfmt.Sprintf(\"%v must provide 'serialize' function. If this custom Scalar \" +\n+\t\t\t\t\t\"is also used as an input type, ensure 'parseValue' and \" +\n+\t\t\t\t\t\"'parseLiteral' functions are also provided.\", scalarType),\n+\t\t\t)\n+\t}\n+/*\n+\t//TODO(akhil): uncomment when implementing input types\n+\t//throw error if any one of parseValue or parseLiteral functions are not provided\n+\t//(in case this scalar type is an input type)\n+\tif (sc.parseValue != nil && sc.parseLiteral == nil) || \n+\t\t (sc.parseValue == nil && sc.parseLiteral != nil) {\n+\t\t \tscalarType.err = makeTypeError(\n+\t\t \t\t\tfmt.Sprintf(\"%v must provide none (non-input type) or both (input type) \n+\t\t \t\t\t\t'parseValue' and 'parseLiteral' functions.\",scalarType)\n+\t\t \t\t)\n+\t}\n+*/\n+\tscalarType.Config = *sc\n+\treturn scalarType\n+}\n+\n+\n+\n+func (s *GraphQLScalar) String() string {\n+\treturn s.Name\n+}\n+\n+func (s *GraphQLScalar) Error() error {\n+\treturn s.Err\n+}\n+\n+/**","path":"types/definitions.go","position":116,"original_position":116,"commit_id":"69cde8627e5c7c5e5b4a70ad32f17fb82aa35333","original_commit_id":"69cde8627e5c7c5e5b4a70ad32f17fb82aa35333","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"comment on exported type GraphQLObject should be of the form \"GraphQLObject ...\" (with optional leading article)","created_at":"2016-08-22T06:23:35Z","updated_at":"2016-08-22T06:23:35Z","html_url":"https://github.com/dgraph-io/dgraph/pull/172#discussion_r75623334","pull_request_url":"https://api.github.com/repos/dgraph-io/dgraph/pulls/172","_links":{"self":{"href":"https://api.github.com/repos/dgraph-io/dgraph/pulls/comments/75623334"},"html":{"href":"https://github.com/dgraph-io/dgraph/pull/172#discussion_r75623334"},"pull_request":{"href":"https://api.github.com/repos/dgraph-io/dgraph/pulls/172"}}},"pull_request":{"url":"https://api.github.com/repos/dgraph-io/dgraph/pulls/172","id":82139355,"html_url":"https://github.com/dgraph-io/dgraph/pull/172","diff_url":"https://github.com/dgraph-io/dgraph/pull/172.diff","patch_url":"https://github.com/dgraph-io/dgraph/pull/172.patch","issue_url":"https://api.github.com/repos/dgraph-io/dgraph/issues/172","number":172,"state":"open","locked":false,"title":"add basic types, sample schema and dummy schema validation skeleton","user":{"login":"akhiltak","id":7594614,"avatar_url":"https://avatars.githubusercontent.com/u/7594614?v=3","gravatar_id":"","url":"https://api.github.com/users/akhiltak","html_url":"https://github.com/akhiltak","followers_url":"https://api.github.com/users/akhiltak/followers","following_url":"https://api.github.com/users/akhiltak/following{/other_user}","gists_url":"https://api.github.com/users/akhiltak/gists{/gist_id}","starred_url":"https://api.github.com/users/akhiltak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akhiltak/subscriptions","organizations_url":"https://api.github.com/users/akhiltak/orgs","repos_url":"https://api.github.com/users/akhiltak/repos","events_url":"https://api.github.com/users/akhiltak/events{/privacy}","received_events_url":"https://api.github.com/users/akhiltak/received_events","type":"User","site_admin":false},"body":"ToDo (before merge to master):\r\n - complete validation and execution step\r\n - add tests for new methods\r\n - squash addition commits (if any)\r\n - fix formatting issues (text editor bugs)\r\n - get LGTM\n\n<!-- Reviewable:start -->\n---\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/dgraph-io/dgraph/172)\n<!-- Reviewable:end -->\n","created_at":"2016-08-22T06:23:24Z","updated_at":"2016-08-22T06:23:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"49826b1825917c082d3453c5fd208a4ec8484063","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dgraph-io/dgraph/pulls/172/commits","review_comments_url":"https://api.github.com/repos/dgraph-io/dgraph/pulls/172/comments","review_comment_url":"https://api.github.com/repos/dgraph-io/dgraph/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dgraph-io/dgraph/issues/172/comments","statuses_url":"https://api.github.com/repos/dgraph-io/dgraph/statuses/69cde8627e5c7c5e5b4a70ad32f17fb82aa35333","head":{"label":"dgraph-io:feature/supporting-types-graphql","ref":"feature/supporting-types-graphql","sha":"69cde8627e5c7c5e5b4a70ad32f17fb82aa35333","user":{"login":"dgraph-io","id":13958706,"avatar_url":"https://avatars.githubusercontent.com/u/13958706?v=3","gravatar_id":"","url":"https://api.github.com/users/dgraph-io","html_url":"https://github.com/dgraph-io","followers_url":"https://api.github.com/users/dgraph-io/followers","following_url":"https://api.github.com/users/dgraph-io/following{/other_user}","gists_url":"https://api.github.com/users/dgraph-io/gists{/gist_id}","starred_url":"https://api.github.com/users/dgraph-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgraph-io/subscriptions","organizations_url":"https://api.github.com/users/dgraph-io/orgs","repos_url":"https://api.github.com/users/dgraph-io/repos","events_url":"https://api.github.com/users/dgraph-io/events{/privacy}","received_events_url":"https://api.github.com/users/dgraph-io/received_events","type":"Organization","site_admin":false},"repo":{"id":41349039,"name":"dgraph","full_name":"dgraph-io/dgraph","owner":{"login":"dgraph-io","id":13958706,"avatar_url":"https://avatars.githubusercontent.com/u/13958706?v=3","gravatar_id":"","url":"https://api.github.com/users/dgraph-io","html_url":"https://github.com/dgraph-io","followers_url":"https://api.github.com/users/dgraph-io/followers","following_url":"https://api.github.com/users/dgraph-io/following{/other_user}","gists_url":"https://api.github.com/users/dgraph-io/gists{/gist_id}","starred_url":"https://api.github.com/users/dgraph-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgraph-io/subscriptions","organizations_url":"https://api.github.com/users/dgraph-io/orgs","repos_url":"https://api.github.com/users/dgraph-io/repos","events_url":"https://api.github.com/users/dgraph-io/events{/privacy}","received_events_url":"https://api.github.com/users/dgraph-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dgraph-io/dgraph","description":"Scalable, Distributed, Low Latency Graph Database","fork":false,"url":"https://api.github.com/repos/dgraph-io/dgraph","forks_url":"https://api.github.com/repos/dgraph-io/dgraph/forks","keys_url":"https://api.github.com/repos/dgraph-io/dgraph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dgraph-io/dgraph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dgraph-io/dgraph/teams","hooks_url":"https://api.github.com/repos/dgraph-io/dgraph/hooks","issue_events_url":"https://api.github.com/repos/dgraph-io/dgraph/issues/events{/number}","events_url":"https://api.github.com/repos/dgraph-io/dgraph/events","assignees_url":"https://api.github.com/repos/dgraph-io/dgraph/assignees{/user}","branches_url":"https://api.github.com/repos/dgraph-io/dgraph/branches{/branch}","tags_url":"https://api.github.com/repos/dgraph-io/dgraph/tags","blobs_url":"https://api.github.com/repos/dgraph-io/dgraph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dgraph-io/dgraph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dgraph-io/dgraph/git/refs{/sha}","trees_url":"https://api.github.com/repos/dgraph-io/dgraph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dgraph-io/dgraph/statuses/{sha}","languages_url":"https://api.github.com/repos/dgraph-io/dgraph/languages","stargazers_url":"https://api.github.com/repos/dgraph-io/dgraph/stargazers","contributors_url":"https://api.github.com/repos/dgraph-io/dgraph/contributors","subscribers_url":"https://api.github.com/repos/dgraph-io/dgraph/subscribers","subscription_url":"https://api.github.com/repos/dgraph-io/dgraph/subscription","commits_url":"https://api.github.com/repos/dgraph-io/dgraph/commits{/sha}","git_commits_url":"https://api.github.com/repos/dgraph-io/dgraph/git/commits{/sha}","comments_url":"https://api.github.com/repos/dgraph-io/dgraph/comments{/number}","issue_comment_url":"https://api.github.com/repos/dgraph-io/dgraph/issues/comments{/number}","contents_url":"https://api.github.com/repos/dgraph-io/dgraph/contents/{+path}","compare_url":"https://api.github.com/repos/dgraph-io/dgraph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dgraph-io/dgraph/merges","archive_url":"https://api.github.com/repos/dgraph-io/dgraph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dgraph-io/dgraph/downloads","issues_url":"https://api.github.com/repos/dgraph-io/dgraph/issues{/number}","pulls_url":"https://api.github.com/repos/dgraph-io/dgraph/pulls{/number}","milestones_url":"https://api.github.com/repos/dgraph-io/dgraph/milestones{/number}","notifications_url":"https://api.github.com/repos/dgraph-io/dgraph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dgraph-io/dgraph/labels{/name}","releases_url":"https://api.github.com/repos/dgraph-io/dgraph/releases{/id}","deployments_url":"https://api.github.com/repos/dgraph-io/dgraph/deployments","created_at":"2015-08-25T07:15:56Z","updated_at":"2016-08-22T03:27:55Z","pushed_at":"2016-08-22T06:23:29Z","git_url":"git://github.com/dgraph-io/dgraph.git","ssh_url":"git@github.com:dgraph-io/dgraph.git","clone_url":"https://github.com/dgraph-io/dgraph.git","svn_url":"https://github.com/dgraph-io/dgraph","homepage":"","size":32665,"stargazers_count":1697,"watchers_count":1697,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":77,"mirror_url":null,"open_issues_count":23,"forks":77,"open_issues":23,"watchers":1697,"default_branch":"master"}},"base":{"label":"dgraph-io:master","ref":"master","sha":"0a5208becbd77e51b908076141284db819cc5e5e","user":{"login":"dgraph-io","id":13958706,"avatar_url":"https://avatars.githubusercontent.com/u/13958706?v=3","gravatar_id":"","url":"https://api.github.com/users/dgraph-io","html_url":"https://github.com/dgraph-io","followers_url":"https://api.github.com/users/dgraph-io/followers","following_url":"https://api.github.com/users/dgraph-io/following{/other_user}","gists_url":"https://api.github.com/users/dgraph-io/gists{/gist_id}","starred_url":"https://api.github.com/users/dgraph-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgraph-io/subscriptions","organizations_url":"https://api.github.com/users/dgraph-io/orgs","repos_url":"https://api.github.com/users/dgraph-io/repos","events_url":"https://api.github.com/users/dgraph-io/events{/privacy}","received_events_url":"https://api.github.com/users/dgraph-io/received_events","type":"Organization","site_admin":false},"repo":{"id":41349039,"name":"dgraph","full_name":"dgraph-io/dgraph","owner":{"login":"dgraph-io","id":13958706,"avatar_url":"https://avatars.githubusercontent.com/u/13958706?v=3","gravatar_id":"","url":"https://api.github.com/users/dgraph-io","html_url":"https://github.com/dgraph-io","followers_url":"https://api.github.com/users/dgraph-io/followers","following_url":"https://api.github.com/users/dgraph-io/following{/other_user}","gists_url":"https://api.github.com/users/dgraph-io/gists{/gist_id}","starred_url":"https://api.github.com/users/dgraph-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dgraph-io/subscriptions","organizations_url":"https://api.github.com/users/dgraph-io/orgs","repos_url":"https://api.github.com/users/dgraph-io/repos","events_url":"https://api.github.com/users/dgraph-io/events{/privacy}","received_events_url":"https://api.github.com/users/dgraph-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dgraph-io/dgraph","description":"Scalable, Distributed, Low Latency Graph Database","fork":false,"url":"https://api.github.com/repos/dgraph-io/dgraph","forks_url":"https://api.github.com/repos/dgraph-io/dgraph/forks","keys_url":"https://api.github.com/repos/dgraph-io/dgraph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dgraph-io/dgraph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dgraph-io/dgraph/teams","hooks_url":"https://api.github.com/repos/dgraph-io/dgraph/hooks","issue_events_url":"https://api.github.com/repos/dgraph-io/dgraph/issues/events{/number}","events_url":"https://api.github.com/repos/dgraph-io/dgraph/events","assignees_url":"https://api.github.com/repos/dgraph-io/dgraph/assignees{/user}","branches_url":"https://api.github.com/repos/dgraph-io/dgraph/branches{/branch}","tags_url":"https://api.github.com/repos/dgraph-io/dgraph/tags","blobs_url":"https://api.github.com/repos/dgraph-io/dgraph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dgraph-io/dgraph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dgraph-io/dgraph/git/refs{/sha}","trees_url":"https://api.github.com/repos/dgraph-io/dgraph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dgraph-io/dgraph/statuses/{sha}","languages_url":"https://api.github.com/repos/dgraph-io/dgraph/languages","stargazers_url":"https://api.github.com/repos/dgraph-io/dgraph/stargazers","contributors_url":"https://api.github.com/repos/dgraph-io/dgraph/contributors","subscribers_url":"https://api.github.com/repos/dgraph-io/dgraph/subscribers","subscription_url":"https://api.github.com/repos/dgraph-io/dgraph/subscription","commits_url":"https://api.github.com/repos/dgraph-io/dgraph/commits{/sha}","git_commits_url":"https://api.github.com/repos/dgraph-io/dgraph/git/commits{/sha}","comments_url":"https://api.github.com/repos/dgraph-io/dgraph/comments{/number}","issue_comment_url":"https://api.github.com/repos/dgraph-io/dgraph/issues/comments{/number}","contents_url":"https://api.github.com/repos/dgraph-io/dgraph/contents/{+path}","compare_url":"https://api.github.com/repos/dgraph-io/dgraph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dgraph-io/dgraph/merges","archive_url":"https://api.github.com/repos/dgraph-io/dgraph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dgraph-io/dgraph/downloads","issues_url":"https://api.github.com/repos/dgraph-io/dgraph/issues{/number}","pulls_url":"https://api.github.com/repos/dgraph-io/dgraph/pulls{/number}","milestones_url":"https://api.github.com/repos/dgraph-io/dgraph/milestones{/number}","notifications_url":"https://api.github.com/repos/dgraph-io/dgraph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dgraph-io/dgraph/labels{/name}","releases_url":"https://api.github.com/repos/dgraph-io/dgraph/releases{/id}","deployments_url":"https://api.github.com/repos/dgraph-io/dgraph/deployments","created_at":"2015-08-25T07:15:56Z","updated_at":"2016-08-22T03:27:55Z","pushed_at":"2016-08-22T06:23:29Z","git_url":"git://github.com/dgraph-io/dgraph.git","ssh_url":"git@github.com:dgraph-io/dgraph.git","clone_url":"https://github.com/dgraph-io/dgraph.git","svn_url":"https://github.com/dgraph-io/dgraph","homepage":"","size":32665,"stargazers_count":1697,"watchers_count":1697,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":77,"mirror_url":null,"open_issues_count":23,"forks":77,"open_issues":23,"watchers":1697,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dgraph-io/dgraph/pulls/172"},"html":{"href":"https://github.com/dgraph-io/dgraph/pull/172"},"issue":{"href":"https://api.github.com/repos/dgraph-io/dgraph/issues/172"},"comments":{"href":"https://api.github.com/repos/dgraph-io/dgraph/issues/172/comments"},"review_comments":{"href":"https://api.github.com/repos/dgraph-io/dgraph/pulls/172/comments"},"review_comment":{"href":"https://api.github.com/repos/dgraph-io/dgraph/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dgraph-io/dgraph/pulls/172/commits"},"statuses":{"href":"https://api.github.com/repos/dgraph-io/dgraph/statuses/69cde8627e5c7c5e5b4a70ad32f17fb82aa35333"}}}}
{"actor":{"display_login":"houndci-bot"}}