Skip to content

Commit

Permalink
feat: log graphql requests (#526)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson authored Nov 5, 2024
1 parent ddb767b commit 174637f
Show file tree
Hide file tree
Showing 12 changed files with 228 additions and 160 deletions.
4 changes: 3 additions & 1 deletion client/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { GraphQLClient } from 'graphql-request';

export const API_URL = process.env.REACT_APP_API_URI;
export const graphQLClient = new GraphQLClient(API_URL!);
export const graphQLClient = new GraphQLClient(API_URL!, {
headers: { 'dgidb-client-name': 'dgidb-frontend' },
});
11 changes: 8 additions & 3 deletions client/src/hooks/queries/useGetAmbiguousResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,14 @@ export function useGetMatchedResults(names: string[], type: ResultTypes) {
return useQuery(
key,
async () => {
const res = await graphQLClient.request(requestQuery, {
searchTerms: names,
});
const res = await graphQLClient.request(
requestQuery,
{ searchTerms: names },
{
'dgidb-query-type':
type === ResultTypes.Gene ? 'search-genes' : 'search-drugs',
}
);
return res;
},
{ enabled: names.length > 0 }
Expand Down
11 changes: 8 additions & 3 deletions client/src/hooks/queries/useGetCategories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ export function useGetCategories(names: string[]) {
return useQuery(
'categories' + names,
async () => {
const res = await graphQLClient.request(getCategoriesQuery, {
searchTerms: names,
});
const res = await graphQLClient.request(
getCategoriesQuery,
{ searchTerms: names },
{
'dgidb-query-type': 'search-genes',
'dgidb-genes-search-mode': 'categories',
}
);
return res;
},
{ enabled: names.length > 0 }
Expand Down
6 changes: 5 additions & 1 deletion client/src/hooks/queries/useGetNameSuggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ export function useGetNameSuggestions(searchTerm: string, type: SearchTypes) {
return useQuery(
queryName + searchTerm,
async () => {
const res = await graphQLClient.request(query, { term: searchTerm });
const res = await graphQLClient.request(
query,
{ term: searchTerm },
{ 'dgidb-query-type': queryName }
);
return res;
},
{ enabled: searchTerm !== '' }
Expand Down
8 changes: 4 additions & 4 deletions server/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ gem "pg", "~>1.2.3"
gem "puma"
gem "rufo"

gem "graphql", "~> 1.12.15"
gem "graphql-batch", "~> 0.4.3"
gem "graphql", "~> 2.3.14"
gem 'graphql-batch', '~>0.5.3'
gem "graphiql-rails", "~> 1.7.0"
gem "search_object_graphql", "0.3.1"
gem "search_object_graphql", "~> 1.0.5"

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", ">= 1.4.4", require: false
Expand All @@ -26,7 +26,7 @@ gem "activestorage", ">= 6.1.4.7"
gem "nokogiri", ">= 1.13.2"

# Importer dependencies
gem "graphql-client"
gem "graphql-client", "~> 0.23.0"
gem "ruby-progressbar"
gem "sqlite3", require: false
gem "zlib", require: false
Expand Down
Loading

0 comments on commit 174637f

Please sign in to comment.