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 GraphQL schema #199

Merged
merged 3 commits into from
Mar 21, 2022
Merged

Add GraphQL schema #199

merged 3 commits into from
Mar 21, 2022

Conversation

s1na
Copy link
Contributor

@s1na s1na commented Mar 14, 2022

The schema can be explored via https://s1na.github.io/graphql-schema-explorer/?url=https://raw.githubusercontent.com/s1na/execution-apis/7b57bc60a59dc5ac8d8bffc0e5df4a12134cf2ae/graphql.json

This was exported from geth which has some EIP-1559 related fields in addition to the eip.

Fixes #163

This is the script I used to generate this against a live node:

const { buildClientSchema, printSchema, getIntrospectionQuery } = require('graphql')
const { request } = require('graphql-request')

const endpoint = 'http://localhost:8545/graphql'

async function main() {
    const q = getIntrospectionQuery()
    const res = await request(endpoint, q)
    const types = []
    console.log(JSON.stringify(res, null, 2))
}

main().then().catch((err) => console.log(err))

Copy link
Member

@lightclient lightclient left a comment

Choose a reason for hiding this comment

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

This is really neat - thanks for this. Do you mind also doing the following:

  1. Add the script you provided into the scripts directory here + adapt it to actually write the schema to the graphql.json file?
  2. Add a CI check to validate the schema (maybe something like this)?

@s1na
Copy link
Contributor Author

s1na commented Mar 16, 2022

Done. Re 2. I use the semantic validation offered by the graphql library itself, but it doesn't check other lint-ish rules like the one you linked. Happy to add that too if you think it helps

Copy link
Member

@lightclient lightclient left a comment

Choose a reason for hiding this comment

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

Thank you! The validator you wrote seems fine. The main thing I want to avoid is having a graphql.json file that can't be consumed for some reason, so it seems like buildClientSchema will catch that.

@lightclient lightclient merged commit cd7f22e into ethereum:main Mar 21, 2022
@s1na s1na deleted the graphql branch May 9, 2022 10:31
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.

Integrate GraphQL schemas
2 participants