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

Initial GraphQL implementation #11

Merged
merged 3 commits into from
Nov 3, 2023
Merged

Initial GraphQL implementation #11

merged 3 commits into from
Nov 3, 2023

Conversation

jazairi
Copy link
Contributor

@jazairi jazairi commented Nov 1, 2023

Why these changes are being introduced:

We need a GraphQL interface to record SearchEvents from TACOS
consumers.

Relevant ticket(s):

https://mitlibraries.atlassian.net/browse/ENGX-234

How this addresses that need:

  • Adds the GraphQL gem and generates a new install.
  • Adds a SearchEvent type and corresponding query field that
    returns information about the search event and creates a new
    SearchEvent (and Term, if applicable).

Side effects of this change:

  • Removed a couple of generated GraphQL test fields.
  • Miscellaneous rubocop fixes.

This adds the GraphQL gem and generates a GraphQL installation.
Why these changes are being introduced:

We need a GraphQL interface to record SearchEvents from TACOS
consumers.

Relevant ticket(s):

https://mitlibraries.atlassian.net/browse/ENGX-234

How this addresses that need:

This adds a SearchEvent type and corresponding query field that
returns information about the search event and creates a new
SearchEvent (and Term, if applicable).

Side effects of this change:

* Removed a couple of generated GraphQL test fields.
* Miscellaneous rubocop fixes.
@jazairi
Copy link
Contributor Author

jazairi commented Nov 1, 2023

To address the coverage issues seems like we would be testing the gem. I'm curious about differing perspectives on this, and whether additional coverage is needed outside of what's being reported.

@JPrevost JPrevost self-assigned this Nov 1, 2023
The introspection query was erroring `Type Mutation must define one or more fields`. Since we don't currently provide a mutation, this should be fine.
description: "An example field added by the generator"
def test_field
"Hello World!"
field :log_search_event, SearchEventType, null: false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to change this now, but I think we may want to be open to changing this name as we start integrating this work with other systems.

TACOS cares about the logging portion of this, but consumers of TACOS in the future are hopefully less concerned with logging and more interested in the structured data we can return. It's also possible there are multiple access points, this one that just logs and a different one in the future that would log and return data... hence my not wanting to worry about the name quite yet as this is currently is well named :)

As the current targeted use is entirely internal for the near future, we can easily update this if we come up with a name that feels more accurate.

# frozen_string_literal: true

module Types
class SearchEventType < Types::BaseObject
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought for the future: I'm waffly (and thus not requesting a change) as to whether it might be good to include the Term.phrase as part of this externally facing object. I know from the data perspective, it is a relation but from the API perspective we may want this to feel like a single object. Hmmm.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same thought and, being similarly ambivalent, stuck to what is contained in the SearchEvent model for now. My expectation is that this type will eventually include a lot of data that it does not currently, including the search phrase. (As you noted, the field name will probably also change to reflect this.) For now, sticking with a basic implementation feels to me like a good approach, given that we'll be extending it in the hopefully near future.

@@ -1,4 +1,8 @@
Rails.application.routes.draw do
if Rails.env.development?
mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "/graphql"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In TIMDEX we've decided to implement GraphiQL as an HTML page instead of via the Gem. I don't remember why, so this isn't a request for a change but just something we should keep our eye on to know whether we should update TIMDEX or TACOS to match the other.

https://github.com/MITLibraries/timdex/blob/main/public/playground.html

If we can configure the Gem version, it may be better as it would fit into our dependency update patterns more easily than the standalone HTML does. 🤷🏻

@JPrevost
Copy link
Member

JPrevost commented Nov 3, 2023

@jazairi I added a commit to address the mutation warning. I am not (currently at least) concerned with the code coverage as that is all generated code as you noted.

@jazairi jazairi merged commit 0b587a2 into main Nov 3, 2023
1 of 2 checks passed
@jazairi jazairi deleted the engx-234-implement-graphql branch November 3, 2023 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants