-
Notifications
You must be signed in to change notification settings - Fork 173
Expose TypeScript Types to Users and Improve node Docs
#199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
node docs
node docsnode docs
node docsnode Docs
slax57
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Let me know if it's working as expected, plus additionally if you'd like me to remove the changes to the example directory from the PR. |
|
@femioladipo Thanks for your reply. |
|
Hi @slax57, yes that too is working for me. In fact it's how I currently have it setup in my project. I vendor'd this PR as a package within my repo and then use a local/path install to link to it. I'm not sure why your setup isn't picking up the types. I also rechecked just now with a minimal setup using just two files in a directory, pasted below. I also setup a temporary repo you can checkout: https://github.com/femioladipo/json-graphql-server-test. Can you check one or both of these? Apologies, if this is a bit laborious, but I feel the issue may be in your setup. While I am really curious what it might be. server.tsimport express from 'express';
import jsonGraphqlExpress, { getPlainSchema } from 'json-graphql-server/node';
const data = {
users: [
{ id: 1, name: 'John Doe', age: 30 },
{ id: 2, name: 'Jane Smith', age: 25 },
{ id: 3, name: 'Alice Johnson', age: 28 },
],
posts: [
{ id: 1, title: 'GraphQL Basics', content: 'Introduction to GraphQL', authorId: 1 },
{ id: 2, title: 'Advanced GraphQL', content: 'Deep dive into GraphQL features', authorId: 2 },
{ id: 3, title: 'GraphQL Best Practices', content: 'Tips and tricks for using GraphQL effectively', authorId: 3 },
],
};
const PORT = 3000;
const app = express();
const plainSchema = getPlainSchema(data);
app.use('/graphql', jsonGraphqlExpress(data));
app.listen(PORT);package.json{
"dependencies": {
"express": "^5.1.0",
"json-graphql-server": "./vendor/json-graphql-server"
}
} |
|
Thanks @femioladipo for taking the time to provide additional tests and information. Anyways, I found the culprit: I was missing the Now the types are properly working so we can consider this issue solved. |
node Docsnode Docs



Description
This PR enables proper TypeScript support and facilitates importing specific functions via the
/nodesubpath export. The changes ensure that existing TypeScript types are properly published and consumers can import functions likejsonSchemaBuilderusingimport { jsonSchemaBuilder } from 'json-graphql-server/node'.Changes Made
package.json
What:
Why:
"types"field to both main and/nodeexports to provide TypeScript declaration files to usersWhat:
Why:
build-tsto the end of the build chain becauseyarn build-esm-cjsremoves all files in/distso anything emitted to/distbeforeyarn build-esm-cjsis removed.tsconfig.json
What:
Why:
"emitDeclarationOnly": true: Generates only .d.ts files without JavaScript output (since Vite handles JS bundling)"declaration": true: Enables generation of TypeScript declaration files"declarationMap": true: Creates source maps for declaration files for better debugging"outDir": "./dist": Specifies output directory for generated declaration filesvite.config.ts
What:
Why:
vite.config.umd.ts, rather than in inferring implicitly.📝 README.md
What:
Why:
This PR addresses the core issue of making existing TypeScript types available to consumers while providing a cleaner import API for the schema builder functionality.
Related Issue
Open issue requesting typescript support