README.md in graphql-remote_loader-1.0.0 vs README.md in graphql-remote_loader-1.0.1

- old
+ new

@@ -4,17 +4,33 @@ Performant, batched GraphQL queries from within the resolvers of a [`graphql-ruby`](https://github.com/rmosolgo/graphql-ruby) API. ## Snippet +For default error handling(null if errors) and no post-processing: + ```ruby - field :login, String, null: false, description: "The currently authenticated GitHub user's login." +field :login, String, null: true, description: "The currently authenticated GitHub user's login." - def login - GitHubLoader.load("viewer { login }").then do |results| - results["viewer"]["login"] +def login + GitHubLoader.load_value("viewer", "login") +end +``` + +If you need error handling, post-processing, or complex queries: + +```ruby +field :login, String, null: false, description: "The currently authenticated GitHub user's login." + +def login + GitHubLoader.load("viewer { login }").then do |results| + if results["errors"].present? + "" + else + results["data"]["viewer"]["login"].upcase end end +end ``` ## Full example To see a working example of how `graphql-remote_loader` works, see the [complete, working example application](https://github.com/d12/graphql-remote_loader_example).