When using the graphql-tools JsonFileLoader with the follow schema.json:
{
"UserObjectType": {
"id": "Int",
"username": "String",
"firstName": "String",
"lastName": "String",
"avatar": "AvatarObjectType",
"dateCreated": "DateTime",
"notificationPreferences": "GenericScalar"
},
"AvatarObjectType": { "id": "Int", "avatarUrl": "String" },
"scalar": ["DateTime", "GenericScalar"],
"Query": {
"GetCurrentUser": "UserObjectType"
}
}
I get the following error:
Unable to find any GraphQL type definitions for the following pointers:
- UserObjectType
,
- AvatarObjectType
,
- scalar
,
- Query
at prepareResult (dist/load/src/load-typedefs.js:70:15)
at loadTypedefs (dist/load/src/load-typedefs.js:35:12)
Here's my code:
const JSONSchema = await loadSchema(schema, {
loaders: [new JsonFileLoader()],
});
const mocks = {
String: () => "abc",
Int: () => 56,
UserObjectType: () => ({
firstName: "John",
lastName: "Smith",
}),
};
// Create a new schema with mocks
const schemaWithMocks = addMocksToSchema({
schema: JSONSchema,
mocks,
});
Reproduction repo is here and more specifically, the test where I use JSONFileLoader is here.
EDIT: I used @graphql-codegen/cli
's introspection plugin to generate a new JSON which you can find here.
When loading this into my test, I get a similar error:
graphql-tools › Runs mocked Schema with JsonFileLoader
Unable to find any GraphQL type definitions for the following pointers:
- __schema
at prepareResult (dist/load/src/load-typedefs.js:70:15)
at loadTypedefs (dist/load/src/load-typedefs.js:35:12)