Tim Holmes-Mitra
11/04/2019, 4:43 PMgraphql-import to play nice with my custom Date scalar running on node + TS. I have four files in my setup with root.graphql as the entry point as so:
# import * from "common.graphql"
# import * from "queries.graphql"
# import * from "mutations.graphql"
type Query {
root: String!
}
type Mutation {
root: String!
}
scalar Date
And the other files are as you would expect. I'm trying to combine my typeDefs as follows:
const typeDefs = importSchema("./src/interfaces/graphql/schema/type-defs/root.graphql")
...
// create ApolloServer
When I run my code this way I get the fol error: UnhandledPromiseRejectionWarning: Error: Query.getProfile defined in resolvers, but not in schema. On console.log(typeDef) it doesn't appear to have loaded the imports because the string only contains whats in root.graphql. I have tried relative paths similar to the path used in importSchema but no joy#. So in playing around I tried:
const schemas = {
common: importSchema("./src/interfaces/graphql/schema/type-defs/common.graphql"),
mutations: importSchema("./src/interfaces/graphql/schema/type-defs/mutations.graphql"),
queries: importSchema("./src/interfaces/graphql/schema/type-defs/queries.graphql"),
}
const typeDefs = importSchema(
"./src/interfaces/graphql/schema/type-defs/root.graphql",
schemas
)
Which gives the follow error: Error: Field starts: Couldn't find type Date in any of the schemas.. If I remove the custom scalar type it runs correctly (or if I put everything into one .graphql file), but for obvious reasons I'd like to use custom scalars and split it into separate files.
Any suggestions?Tim Holmes-Mitra
11/04/2019, 7:32 PM