Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShopifyEng/7571450024f1d8ed575cfdd5dba695f1 to your computer and use it in GitHub Desktop.
Save ShopifyEng/7571450024f1d8ed575cfdd5dba695f1 to your computer and use it in GitHub Desktop.
GraphQL Server Best Practices
class Types::CustomerType < Types::BaseObject
implements GraphQL::Relay::Node.interface
def self.object_from_id(id, context)
CustomerRepository.find(context[:seller], id: id) # or: context[:seller].customers.find_by(id: id)
end
field :name, String, null: true
field :name, Email, null: true
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment