Hi,
Is there a compatibility issue with grapql-scalars and buildSubgraphSchema?
I’m getting an error when using DateTime:
TypeError: doc.definitions is not iterable (cannot read property undefined)
at concatAST (/Users/taranro/IdeaProjects/myweather/node_modules/graphql/utilities/concatAST.js:19:17)
Here’s the Apollo example with DateTime added:
import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
import gql from 'graphql-tag';
import { buildSubgraphSchema } from '@apollo/subgraph';
import {resolvers as scalarResolvers, typeDefs as scalarTypeDefs} from "graphql-scalars";
import {typeDefs as myTypeDefs} from "./graphql/schema/weatherschema.js";
import {resolvers as myResolvers} from "./graphql/resolvers/weatherresolvers.js";
const typeDefs = gql`
extend schema @link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@key", "@shareable"])
type Query {
me: User
}
type User @key(fields: "id") {
id: ID!
username: String
birthday: DateTime
}
`;
const resolvers = {
Query: {
me() {
return { id: '1', username: '@ava' };
},
},
User: {
__resolveReference(user, { fetchUserById }) {
return fetchUserById(user.id);
},
},
};
const allTypeDefs = [...scalarTypeDefs, typeDefs];
const allResolvers = {...scalarResolvers, ...resolvers};
const server = new ApolloServer({
schema: buildSubgraphSchema({ allTypeDefs, allResolvers }),
});
const { url } = await startStandaloneServer(server);
console.log(`🚀 Server ready at ${url}`);
Getting when running:
definitions.push(...doc.definitions);
^
TypeError: doc.definitions is not iterable (cannot read property undefined)
at concatAST (/Users/taranro/IdeaProjects/myweather/node_modules/graphql/utilities/concatAST.js:19:17)
at buildSubgraphSchema (/Users/IdeaProjects/myweather/node_modules/@apollo/subgraph/dist/buildSubgraphSchema.js:26:49)
at file:///Users/IdeaProjects/myweather/i.js:40:13
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
at async loadESM (node:internal/process/esm_loader:91:5)
at async handleMainPromise (node:internal/modules/run_main:65:12)
Node.js v18.12.1
Thanks,
Roy