Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL + ElasticSearch #533

Open
toastercup opened this issue Oct 18, 2017 · 16 comments
Open

GraphQL + ElasticSearch #533

toastercup opened this issue Oct 18, 2017 · 16 comments

Comments

@toastercup
Copy link
Member

toastercup commented Oct 18, 2017

JIRA:

https://careerbuilder.atlassian.net/browse/CE-307 (GraphQL)
https://careerbuilder.atlassian.net/browse/CE-160 (ElasticSearch Infrastructure)
https://careerbuilder.atlassian.net/browse/CE-503 (ElasticSearch FieldType Mappings)

MVP Features:

  • Queries for ContentItems, FieldItems, Fields, Users and Tenants, with basic arguments (find by ID)
  • Embedded GraphQL IDE
  • Batched + Preloaded queries to avoid N+1 Query issues
  • Rudimentary self-documented ObjectTypes
  • ActiveRecord backend, no ElasticSearch utilization yet. ElasticSearch required for release of Advice & Resources
  • No Sorting/Filtering/Searching Filtering and searching required for release of Advice & Resources
  • No Pagination Pagination required for release of Advice & Resources
  • No Mutations
  • No DevKey Authentication yet
  • No Authorization yet

Helpful resources:

@toastercup
Copy link
Member Author

@toastercup toastercup changed the title GraphQL GraphQL + ElasticSearch Nov 2, 2017
@toastercup
Copy link
Member Author

Particularly relevant; an ElasticSearch query builder DSL: https://github.com/elastic/elasticsearch-ruby/tree/master/elasticsearch-dsl

@toastercup
Copy link
Member Author

graphql-ruby also has its own JS client: http://graphql-ruby.org/javascript_client/overview.html
It also supports subscriptions with Apollo Client: http://graphql-ruby.org/javascript_client/apollo_subscriptions.html

@toastercup
Copy link
Member Author

This is what I've been loosely following for dynamically generating the schema for FieldItems: http://graphql-ruby.org/schema/dynamic_schema.html

@toastercup
Copy link
Member Author

We'll be using Rails's built-in API key functionality to authenticate API users: http://api.rubyonrails.org/classes/ActiveRecord/SecureToken/ClassMethods.html

@toastercup
Copy link
Member Author

toastercup commented Nov 8, 2017

Good rundown of GraphQL Query core concepts with proper terminology: https://dev-blog.apollodata.com/the-anatomy-of-a-graphql-query-6dffa9e9e747

@toastercup
Copy link
Member Author

This will yield a huge benefit over how I was doing things: http://graphql-ruby.org/types/abstract_types.html

We can now group together a bunch of disparate FieldType ObjectTypes under a FieldItem abstract type, vastly simplifying our implementation and querying interface

@toastercup
Copy link
Member Author

And an invaluable explanation of Interfaces and Unions: https://medium.com/the-graphqlhub/graphql-tour-interfaces-and-unions-7dd5be35de0d

@toastercup
Copy link
Member Author

The approach I'm taking tonight (which should hopefully work) is to dynamically define Fields for all ContentTypes in the entire system, then whitelist access per-user by following this guide's recommendations: http://graphql-ruby.org/schema/limiting_visibility.html

@toastercup
Copy link
Member Author

For a truly clean query interface (dynamic, per-user schemas and fields that don't rely on field hiding), we need to wait for the GraphQL-Ruby author to merge rmosolgo/graphql-ruby#1037. This is almost a complete rewrite of the library that will allow us to pass arguments into an ObjectType definition. Until then, we'll have to make do with a query interface that's a bit more verbose, and is not self-documenting in all places.

@toastercup
Copy link
Member Author

Something nifty I'd found but forgot to link to: https://github.com/karmi/es-rails-example

@toastercup
Copy link
Member Author

And then GraphCMS comes along and blows our API out of the water.. https://graphiql.graphcms.com/simple/v1/swapi

We'll get there, though!

@toastercup
Copy link
Member Author

Decently hefty Rails example: https://github.com/howtographql/graphql-ruby

@toastercup
Copy link
Member Author

Sane structure guideline to help clean up our QueryType: https://m.alphasights.com/graphql-ruby-clean-up-your-query-type-d7ab05a47084

@toastercup
Copy link
Member Author

graphql-ruby 1.8pre has been released, which will allow us to create per-user GraphQL schemas (which will hide irrelevant ContentTypes and Fields): https://github.com/rmosolgo/graphql-ruby/blob/1.8-dev/guides/schema/class_based_api.md

@toastercup
Copy link
Member Author

Partially resolved by #536. Keeping this issue open to plan future refactors and features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant