Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gqty-dev/gqty
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5b448ddfcdb83f79ce991010f576b2d3fce28b6e
Choose a base ref
..
head repository: gqty-dev/gqty
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6180ef104466f419322c15f2c2f05c5974e445c6
Choose a head ref
Showing with 247 additions and 50 deletions.
  1. +5 −0 .changeset/curvy-dragons-smell.md
  2. +201 −7 .gitignore
  3. +16 −4 packages/cli/src/config.ts
  4. +22 −26 packages/cli/src/generate.ts
  5. +1 −0 packages/cli/test/config.test.ts
  6. +2 −13 pnpm-lock.yaml
5 changes: 5 additions & 0 deletions .changeset/curvy-dragons-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@gqty/cli': minor
---

feat: Support "endpoint" in configuration
208 changes: 201 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,205 @@
#
# React
#

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Keys
*.pem

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage/
*.lcov

# nyc test coverage
.nyc_output

# jest cache
.jest/

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt/

# Bower dependency directory (https://bower.io/)
bower_components/

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
node_modules.nosync/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm/

# Optional yarn cache directory
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# parcel-bundler cache (https://parceljs.org/)
.cache/

# next.js build output
.next/
out/

# vercel
.vercel/

# nuxt.js build output
.nuxt/

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/
.webpack/
.esbuild/
.warmup/

# Serverless Webpack
.build/
build/

# Serverless Warmup Plugin
.warmup/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# dependencies
.pnp/
.pnp.js

#
# React Native
#

# Windows
Thumbs.db

# OSX
.DS_Store

# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
.idea
.gradle
local.properties
gradle.properties
*.iml

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle

# Ruby / CocoaPods
/ios/Pods/
/vendor/bundle/

# Docusurus build info
.docusaurus

# DotEnv
.env
.env.*

# Local Netlify folder
.netlify/

# Vscode plug-in setting
.graphqlrc.yml

# Local notes
.*.md
/src/config.[tj]s

# GQty build artifacts
dist
.nyc_output
coverage
.next

# GQty test artifacts
examples/react/db.json
examples/react/last-browser-open
*.tsbuildinfo
.docusaurus
build
.env
20 changes: 16 additions & 4 deletions packages/cli/src/config.ts
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import { formatPrettier } from './prettier';

const cjsRequire = globalThis.require || createRequire(import.meta.url);

export type GQtyConfig = Omit<GenerateOptions, 'endpoint'> & {
export type GQtyConfig = GenerateOptions & {
/**
* Introspection options
*/
@@ -33,8 +33,11 @@ function isStringRecord(v: unknown): v is Record<string, string> {

export const DUMMY_ENDPOINT = 'SPECIFY_ENDPOINT_OR_SCHEMA_FILE_PATH_HERE';

export const defaultConfig: Omit<Required<GQtyConfig>, 'transformSchema'> &
Pick<GQtyConfig, 'transformSchema'> = {
export const defaultConfig: Omit<
Required<GQtyConfig>,
'endpoint' | 'transformSchema'
> &
Pick<GQtyConfig, 'endpoint' | 'transformSchema'> = {
react: (() => {
try {
cjsRequire.resolve('react');
@@ -50,6 +53,7 @@ export const defaultConfig: Omit<Required<GQtyConfig>, 'transformSchema'> &
endpoint: DUMMY_ENDPOINT,
headers: {} as Record<string, string>,
},
endpoint: '/api/graphql',
destination: './src/gqty/index.ts',
subscriptions: false,
javascriptOutput: false,
@@ -122,6 +126,14 @@ export function getValidConfig(v: unknown): GQtyConfig {
}
break;
}
case 'endpoint': {
if (value && typeof value === 'string') {
newConfig[key] = value;
} else {
warnConfig(key, value, 'string', defaultConfig[key]);
}
break;
}
case 'introspection': {
if (isPlainObject(value)) {
const introspectionOptions: IntrospectionOptions = {};
@@ -262,7 +274,7 @@ export const gqtyConfigPromise: Promise<{
* @type {import("@gqty/cli").GQtyConfig}
*/
const config = ${JSON.stringify(config)};
module.exports = config;`)
);
}
Loading