Comments (17)
One thing that I think will be really useful is a standard config for where to get a schema for the various dev tools, like a graphql-config.json
or something. Maybe it would be like:
{
// Tell tools/editors where to find your schema for validation
schema: {
// One of the below
introspectionJSON: "./data.json",
schemaModule: "./schema.js",
// Allow running actual queries from your editor maybe?
endpointUrl: "http://localhost:3000/graphql",
},
// If you want to keep your queries in separate files
queryFiles: {
fileExtension: "gql",
},
// Configure various linters
lint: {
templateTagName: "gql",
},
// .. options for other plugins here
}
That way, if different developers on your team are using different editors, they can share configuration about your GraphQL-based project.
from graphql-tools.
You can easily run the linter during CI.
from graphql-tools.
Is there a recommendation for people who are not using Javascript?
from graphql-tools.
@mquandalle I'm working on a linter to do this today, let's see how that goes!
from graphql-tools.
One issue with the specific idea above is that ./schema.js
would be the most convenient way to do it, but if that JS file requires any transpilation at all -- it's using babel/ts/coffee -- then the linter/completer module will need to be able to interpret the code. So maybe the introspection result is the only feasible way to do it..
from graphql-tools.
Yes we should rely on the client-server model of GraphQL to do things like query validation or autocompletion (as discussed in https://github.com/apollostack/vscode-graphql/issues/2). We shouldn’t try to emulate a server by taking a schema.js
as we will always miss a lot of the server context, ie transpilation as you say or even tricker things like dynamic schemas—imagine a modular app where extensions can modify the GraphQL schema.
The sad part is that in local dev mode, developers will have to launch a GraphQL server to benefit from the features we are discussing, but I would say that with the tooling available today this shouldn’t be much of an issue.
from graphql-tools.
Yeah, I'm so sad about having to run a server. But I guess having a simple script to do that and print out an introspection JSON wouldn't be a big deal.
from graphql-tools.
The linter approach is one way, but doing things the way adrenaline does it (i.e. mocha/chai) is also quite nice.
We could do the same, but we probably have to implement it in a more generic way that just takes a query and a schema and checks the validity. People could then build on that to implement react, angular and other integrations.
@mquandalle thoughts?
from graphql-tools.
I'm pretty sure linting is better because you get the warnings in your editor directly, and it gives you the line number where you typed your query in the code. But if someone builds a mocha thing that's cool too!
from graphql-tools.
I think you'd probably want both, so you can find errors during CI tests.
from graphql-tools.
For anyone that comes by this thread, the linter works: https://github.com/apollostack/eslint-plugin-graphql
Not sure if that means the issue should be closed or not.
from graphql-tools.
Going to close this issue in favor of https://github.com/apollostack/eslint-plugin-graphql and https://github.com/apollostack/graphqlrc
from graphql-tools.
What are you up to, how are you writing your queries, and what's your goal?
from graphql-tools.
I'm writing an application that talks to a graphql server, I'm writing my queries in plain text files and i would like to be able to type check them on my ci server against a downloaded schema.
from graphql-tools.
you can use this package as-is since it can also read in .graphql files! But if you look at the source code it's also easy to write your own tools using graphql-js
from graphql-tools.
Sorry by "this package" I mean the eslint plugin.
from graphql-tools.
Oh wonderful, thank you. :)
from graphql-tools.
Related Issues (20)
- Project Roadmap HOT 2
- Drop dependency on fast-url-parser HOT 2
- DEBUG=1 results in console.time() warnings
- @graphql-tools/mock does not work with Vitest HOT 5
- Deterministic (seeded) enum values
- Stitching: object field is null when all selections are delegated
- Http Executor encodes headers into query parameters which can leak Authorization headers
- Ability to get names of all the stitched queries in a middleware
- requireResolversToMatchSchema: 'warn' throws an error
- Support .astro file loading on graphql-tag-pluck HOT 1
- Troubles with connectionParams on subscriptions
- Adding content-type header is not supported when fetching schema
- Query does not provide a operation name as a property in the request body causing some server configurations to reject the request
- @graphql-tools/mock 9.0.1 causes panic: Internal errors HOT 2
- @graphql-tools/merge directive arguments compare should not require identical ordering HOT 1
- load babel options in `graphql-tag-pluck`
- [mock] relayStylePaginationMock sometimes returns an incorrect value for hasNextPage
- Batch execution throws an error when Array.prototype has additional property
- Federation @join__field requires parameter handling improvement
- filterSchema argumentFilter provides incorrect typeName
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-tools.