@@ -6,29 +6,44 @@ import {
66 TracingState ,
77 setSpanNameFromGraphQLContext ,
88} from './tracing/tracer.js' ;
9+ import { join } from 'path' ;
10+
11+ const graphqlSchemaPath = join ( __dirname , '..' , 'schema.graphql' ) ;
912
1013const fullResolvers : Resolvers = {
1114 Query : {
1215 events : async ( _ , { input } , context ) => {
13- const graphQLSpan = setSpanNameFromGraphQLContext ( context , 'events.graphql' ) ;
16+ const graphQLSpan = setSpanNameFromGraphQLContext (
17+ context ,
18+ 'events.graphql'
19+ ) ;
1420 return context . db_client . getEvents ( input , {
1521 tracingState : new TracingState ( graphQLSpan ) ,
1622 } ) ;
1723 } ,
1824 actions : async ( _ , { input } , context ) => {
19- const graphQLSpan = setSpanNameFromGraphQLContext ( context , 'actions.graphql' ) ;
25+ const graphQLSpan = setSpanNameFromGraphQLContext (
26+ context ,
27+ 'actions.graphql'
28+ ) ;
2029 return context . db_client . getActions ( input , {
2130 tracingState : new TracingState ( graphQLSpan ) ,
2231 } ) ;
2332 } ,
2433 networkState : async ( _ , __ , context ) => {
25- const graphQLSpan = setSpanNameFromGraphQLContext ( context , 'networkState.graphql' ) ;
34+ const graphQLSpan = setSpanNameFromGraphQLContext (
35+ context ,
36+ 'networkState.graphql'
37+ ) ;
2638 return context . db_client . getNetworkState ( {
2739 tracingState : new TracingState ( graphQLSpan ) ,
2840 } ) ;
2941 } ,
3042 blocks : async ( _ , { query, limit, sortBy } , context ) => {
31- const graphQLSpan = setSpanNameFromGraphQLContext ( context , 'blocks.graphql' ) ;
43+ const graphQLSpan = setSpanNameFromGraphQLContext (
44+ context ,
45+ 'blocks.graphql'
46+ ) ;
3247 return context . db_client . getBlocks ( query , limit , sortBy , {
3348 tracingState : new TracingState ( graphQLSpan ) ,
3449 } ) ;
@@ -41,7 +56,9 @@ let typeDefs: string | undefined = undefined;
4156
4257// If the ENABLED_QUERIES environment variable is set, filter the schema and resolvers.
4358if ( process . env . ENABLED_QUERIES !== undefined ) {
44- const enabledQueries = process . env . ENABLED_QUERIES . split ( ',' ) . map ( ( q ) => q . trim ( ) ) ;
59+ const enabledQueries = process . env . ENABLED_QUERIES . split ( ',' ) . map ( ( q ) =>
60+ q . trim ( )
61+ ) ;
4562
4663 // If the list is not empty, filter the resolvers.
4764 if ( enabledQueries . length > 0 ) {
@@ -54,7 +71,7 @@ if (process.env.ENABLED_QUERIES !== undefined) {
5471 } ;
5572
5673 // Filter the schema AST.
57- const typeDefsString = fs . readFileSync ( './schema.graphql' , 'utf-8' ) ;
74+ const typeDefsString = fs . readFileSync ( graphqlSchemaPath , 'utf-8' ) ;
5875 const typeDefsAst = parse ( typeDefsString ) ;
5976 const modifiedAst = visit ( typeDefsAst , {
6077 ObjectTypeDefinition ( node ) {
@@ -76,7 +93,7 @@ if (process.env.ENABLED_QUERIES !== undefined) {
7693// Create the executable schema.
7794const schema = makeExecutableSchema ( {
7895 resolvers : [ resolvers ] ,
79- typeDefs : typeDefs || fs . readFileSync ( './schema.graphql' , 'utf-8' ) ,
96+ typeDefs : typeDefs || fs . readFileSync ( graphqlSchemaPath , 'utf-8' ) ,
8097} ) ;
8198
8299export { resolvers , schema } ;
0 commit comments