GQLPT + APIPT: The Complete Solution for Natural Language API Interactions

GQLPT is an innovative npm package that leverages the power of AI to generate GraphQL queries from plain text. This cutting-edge tool is designed to streamline the development process and make working with GraphQL more accessible and efficient for developers of all levels.
GQLPT and APIPT: Production-Ready Natural Language API Integration
While GQLPT provides powerful open-source capabilities for GraphQL query generation, APIPT builds upon this foundation to deliver a complete, production-ready solution for natural language API interactions. APIPT extends GQLPT's capabilities with:
- Enterprise-Grade Security: Built-in security controls, role-based access, and encrypted schema storage
- Multi-Protocol Support: Beyond GraphQL, supporting REST APIs and SQL databases
- Advanced Caching: Intelligent query caching with automatic invalidation
- Team Collaboration: Built-in workspace management and access controls
- Vector Embeddings: Enhanced schema understanding through semantic vectorization
- Zero Data Storage: Process queries without storing sensitive API response data
For production deployments and enterprise use cases, we recommend using APIPT which provides these additional features while maintaining full compatibility with GQLPT's core functionality.
What is GQLPT?
GQLPT is a powerful npm package that allows developers to generate GraphQL queries using natural language. Instead of manually constructing complex queries, you can simply describe what data you need in plain English, and GQLPT will do the heavy lifting for you.
Key Features
-
AI-Powered Query Generation: GQLPT uses advanced AI models to interpret your plain text descriptions and generate accurate GraphQL queries.
-
Flexible Adapters: The package supports multiple AI services through its adapter system. Currently, it offers adapters for Anthropic and OpenAI.
-
Schema Introspection: GQLPT can connect directly to your GraphQL endpoint and introspect the schema, ensuring that generated queries are always up-to-date.
-
Generate and Send: With the generateAndSend method, GQLPT can not only generate queries but also send them directly to your GraphQL endpoint.
-
Bring Your Own AI: GQLPT operates on a "bring your own AI" model. You need to supply your own API key for either OpenAI or Anthropic to use their respective adapters.
-
Automatic Type Generation: GQLPT offers seamless type generation without requiring changes to your existing code, enhancing type safety in your projects.
GQLPT in Action
Here's a glimpse of the GQLPT playground in action:
We encourage you to try out the GQLPT playground at gqlpt.dev. It's a great way to experience the power of AI-generated GraphQL queries firsthand!
Getting Started with GQLPT
Let's walk through the process of setting up and using GQLPT in your project:
Installation
First, install GQLPT and the OpenAI adapter:
npm install gqlpt @gqlpt/adapter-openai
Basic Usage
Here's a simple example of how to use GQLPT:
import { AdapterOpenAI } from '@gqlpt/adapter-openai';
import { GQLPTClient } from 'gqlpt';
const typeDefs = /* GraphQL */ `
type User {
id: ID!
name: String!
}
type Query {
user(id: ID!): User
}
`;
const client = new GQLPTClient({
typeDefs,
adapter: new AdapterOpenAI({
apiKey: process.env.OPENAI_API_KEY, // Make sure to provide your OpenAI API key
}),
});
async function main() {
await client.connect();
const query = 'Find users by id 1';
const response = await client.generateQueryAndVariables(query);
console.log(response);
// This would log something like:
// {
// query: `
// query ($id: ID!) {
// user(id: $id) {
// id
// name
// }
// }
// `,
// variables: { id: "1" }
// }
}
main();
Note: Remember to supply your own OpenAI API key in the above example.
Using Introspection
GQLPT can fetch your schema directly from your GraphQL endpoint:
const client = new GQLPTClient({
url: 'http://your-graphql-endpoint.com/graphql',
adapter: new AdapterOpenAI({ apiKey: process.env.OPENAI_API_KEY }),
});
await client.connect(); // Performs introspection
Generate and Send
For a complete end-to-end solution, use the generateAndSend method:
const response = await client.generateAndSend('Find users by id 1');
console.log(response);
// This would log something like:
// {
// data: {
// user: {
// id: "1",
// name: "John Doe"
// }
// }
// }
Automatic Type Generation
GQLPT offers seamless type generation without requiring changes to your existing code. This feature enhances type safety in your projects and improves the developer experience.
Installing the CLI Tool
To use the type generation feature, first install the GQLPT CLI tool:
npm install -g @gqlpt/cli
Generating Types
Run the following command in your project root to generate types:
npx @gqlpt/cli generate ./src
This command will:
- Scan your
./src
directory for GQLPT usage - Generate TypeScript types based on your plain text queries
- Update the types in
node_modules/gqlpt/build/types.d.ts
You don't need to manually import or reference these types in your code. GQLPT will automatically use them to provide type safety.
Example: Querying GitHub API with Automatic Type Safety
Here's an example of how to use GQLPT with the GitHub GraphQL API, leveraging automatically generated types:
import { AdapterOpenAI } from '@gqlpt/adapter-openai';
import { GQLPTClient } from 'gqlpt';
const client = new GQLPTClient({
url: 'https://api.github.com/graphql',
headers: {
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
},
adapter: new AdapterOpenAI({
apiKey: process.env.OPENAI_API_KEY,
}),
});
async function searchGitHubRepos() {
await client.connect();
const query = 'Find repositories with the name gqlpt';
const response = await client.generateAndSend(query);
console.log(response);
// This would log something like:
// {
// data: {
// search: {
// edges: [
// {
// node: {
// name: "gqlpt",
// description: "AI-powered GraphQL query generation",
// url: "https://github.com/example/gqlpt"
// }
// },
// // ... more results
// ]
// }
// }
// }
}
In this example, TypeScript provides full type safety and autocompletion when working with the response, based on the automatically generated types.
Real-World Benefits
- Faster Development: Spend less time writing complex queries and more time building features.
- Improved Accessibility: Make GraphQL more accessible to team members who might not be GraphQL experts.
- Reduced Errors: AI-generated queries can help reduce syntax errors and improve query accuracy.
- Flexibility: Easily switch between different AI providers using the adapter system.
- Enhanced Type Safety: Automatic type generation improves code quality and developer experience.
Getting Started with Production Deployment
While GQLPT is perfect for individual developers and smaller projects, organizations looking for a production-ready solution should consider APIPT. Here's how to get started:
- Evaluate APIPT: Visit apipt.dev to explore the full feature set
- Request a Demo: Book a demo to see APIPT in action with your specific use case
- Review Security: Check out our security features for enterprise-grade protection
- Compare Plans: View our pricing plans to find the right fit for your organization
APIPT offers everything you love about GQLPT, enhanced with production-ready features and enterprise support. Whether you're scaling up a successful project or starting a new enterprise implementation, APIPT provides the robust foundation you need.
Community and Support
We value community involvement and contributions! Here's how you can get involved:
- GitHub Repository: Star our repository to show your support and stay updated with the latest developments.
- Create Issues: Have ideas for improvements or found a bug? Create an issue and let us know!
- Contribute: We welcome contributions! Check out our contributing guidelines to get started.
- GQLPT Playground: Try out GQLPT and provide feedback.
- npm Package: Check out our npm page for the latest versions and documentation.
Conclusion
GQLPT and APIPT together represent the complete spectrum of natural language API interaction solutions. While GQLPT continues to serve as an excellent open-source tool for developers, APIPT builds upon its foundation to provide enterprise-ready features and production deployment capabilities.
For developers starting their journey with AI-powered API interactions, GQLPT offers an accessible entry point. For organizations ready to deploy in production, APIPT provides the security, scalability, and support needed for enterprise implementations.
Experience the power of natural language API interactions today - start with GQLPT for development and seamlessly transition to APIPT for production deployment.