SudhagarS / graphql-type-decimal

Decimal scalar type for Graphql to represent currencies
6 stars 0 forks source link

unable to identify the new type #9

Open kp8910 opened 4 months ago

kp8910 commented 4 months ago
/* eslint-disable prettier/prettier */
import { GraphQLSchema, print } from 'graphql';
import gql from 'graphql-tag';
import { loadFilesSync } from '@graphql-tools/load-files';
import { mergeTypeDefs } from '@graphql-tools/merge';
import { buildSubgraphSchema } from '@apollo/subgraph';
import {
  DateTypeDefinition,
  // TimeTypeDefinition,
  DateResolver,
  TimeResolver,
  DateTimeResolver,
  TimestampTypeDefinition,
} from 'graphql-scalars';
import GraphQLDecimal from 'graphql-type-decimal';

const DecimalDefinition = `
scalar Decimal
`;

const buildSchema = (schemaPath: string, resolvers: any): GraphQLSchema => {
  const typesArray = loadFilesSync(schemaPath);
  if (typesArray.length <= 0) {
    throw Error(`No schema files found with file glob pattern: ${schemaPath}`);
  }
  const typeDefs = mergeTypeDefs([
    ...typesArray,
    DateTypeDefinition,
    // TODO: put this back after account-graphql-service removes "Time" type
    // TimeTypeDefinition,
    TimestampTypeDefinition,
    DecimalDefinition,
  ]);
  const schema = buildSubgraphSchema([
    {
      typeDefs: gql(print(typeDefs)),
      resolvers: {
        ...resolvers,
        Date: DateResolver,
        Time: TimeResolver,
        // graphql-scalars calls this Datetime what we call Timestamp
        Timestamp: DateTimeResolver,
        Decimal: GraphQLDecimal,
      },
    },
  ]);
  return schema;
};
export default buildSchema;

I am trying to integrate the new type in existing code, but it is not identifying the new type, can you help me out in configuring the new type

kp8910 commented 3 months ago

@SudhagarS can you help me with the above?