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

Add Discovery Apollo GraphQL server #5145

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Add Discovery Apollo GraphQL server #5145

wants to merge 3 commits into from

Conversation

nicoback2
Copy link
Contributor

Description

-Add new container containing an apollo graphql server to be run on discovery nodes

Tests

Monitoring - How will this change be monitored? Are there sufficient logs / alerts?

Copy link
Contributor

@sliptype sliptype left a comment

Choose a reason for hiding this comment

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

Great stuff! I do think we should look into how to make this a discovery plugin, since that's the pattern other new things are following

sourceType: 'module'
},
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
Copy link
Contributor

Choose a reason for hiding this comment

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

Will be nice to use shared eslint once monorepo is a thing!

// }

// type Track {
// blocknumber: Int!
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh nice, thanks for creating schemas for all these already!

@@ -30,6 +29,7 @@ x-common:
- "audius-protocol-storagev2-1:host-gateway"
- "audius-protocol-storagev2-2:host-gateway"
- "audius-protocol-storagev2-3:host-gateway"
- "audius-protocol-discovyer-provider-graphql:host-gateway"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- "audius-protocol-discovyer-provider-graphql:host-gateway"
- "audius-protocol-discovery-provider-graphql:host-gateway"

Comment on lines +7 to +32
// type TrackSegment {
// duration: String!
// multihash: String!
// }

// type Followee {
// user: User!
// is_delete: Boolean!
// repost_item_id: String!
// repost_type: String!
// }

// type Download {
// is_downloadable: Boolean
// requires_follow: Boolean
// cid: String
// }

// type FieldVisibility {
// genre: Boolean!
// mood: Boolean!
// tags: Boolean!
// share: Boolean!
// play_count: Boolean!
// remixes: Boolean!
// }
Copy link
Contributor

Choose a reason for hiding this comment

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

nice! did you generate these using a tool or are they hand written?

Comment on lines +7 to +16
const dbConfig = {
client: 'pg',
connection: {
host: 'db',
port: 5432,
user: 'postgres',
password: 'postgres',
database: 'audius_discovery'
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

it may be simpler to use a connection string like our other knex/ts apps, that way if any of the configuration changes it's only in the url, plus you can gather it right from the discovery .env file

example of how the notifications plugin does it:
https://github.com/AudiusProject/audius-protocol/blob/main/discovery-provider/plugins/notifications/src/conn.ts

Comment on lines +10 to +14
.where('is_current', true)

if (res.length !== 1) {
throw new Error('Expected SINGLE row in blocks marked as current')
}
Copy link
Contributor

Choose a reason for hiding this comment

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

you can add a .first() here and avoid this check as well as the throwing
https://knexjs.org/guide/query-builder.html#first


export const DiscoveryDB = (dbConnection: Knex) => {
const blockConfirmationDataLoader = new DataLoader(
async (blockNumbers: readonly number[]) => {
Copy link
Contributor

@alecsavvy alecsavvy May 2, 2023

Choose a reason for hiding this comment

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

i'm curious, is the readonly annotation required for GQL queries?

Comment on lines +19 to +22
"knex": "2.4.2",
"lodash": "4.17.21",
"pg": "8.10.0",
"sequelize": "6.31.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

are knex and sequelize both required? seems like sequelize could be removed

@@ -310,6 +311,7 @@ def load_env(protocol_dir, service, environment):
@click.option(
"--no-solana", is_flag=True, help="Don't bring up solana-test-validator container"
)
@click.option("--no-graphql", is_flag=True, help="Don't bring up graphql container")
Copy link
Contributor

Choose a reason for hiding this comment

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

i know this kind of goes against the established pattern but shouldn't the default here be to not start up the gql container? that way we have to explicitly bring it up until it's ready for release, that also would avoid the need for other to pass this flag just to run their local stack

Comment on lines +17 to +24
ARG git_sha
ARG audius_loggly_disable
ARG audius_loggly_token
ARG audius_loggly_tags

ENV GIT_SHA=$git_shas
ENV audius_loggly_disable=$audius_loggly_disable
ENV audius_loggly_token=$audius_loggly_token
Copy link
Contributor

Choose a reason for hiding this comment

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

do we use loggly anymore?

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

Successfully merging this pull request may close these issues.

5 participants