GithubHelp home page GithubHelp logo

Comments (17)

stubailo avatar stubailo commented on May 1, 2024 4

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.

stubailo avatar stubailo commented on May 1, 2024 2

You can easily run the linter during CI.

from graphql-tools.

lpil avatar lpil commented on May 1, 2024 1

Is there a recommendation for people who are not using Javascript?

from graphql-tools.

stubailo avatar stubailo commented on May 1, 2024

@mquandalle I'm working on a linter to do this today, let's see how that goes!

from graphql-tools.

stubailo avatar stubailo commented on May 1, 2024

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.

mquandalle avatar mquandalle commented on May 1, 2024

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.

stubailo avatar stubailo commented on May 1, 2024

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.

helfer avatar helfer commented on May 1, 2024

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.

stubailo avatar stubailo commented on May 1, 2024

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.

helfer avatar helfer commented on May 1, 2024

I think you'd probably want both, so you can find errors during CI tests.

from graphql-tools.

stubailo avatar stubailo commented on May 1, 2024

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.

stubailo avatar stubailo commented on May 1, 2024

Going to close this issue in favor of https://github.com/apollostack/eslint-plugin-graphql and https://github.com/apollostack/graphqlrc

from graphql-tools.

stubailo avatar stubailo commented on May 1, 2024

What are you up to, how are you writing your queries, and what's your goal?

from graphql-tools.

lpil avatar lpil commented on May 1, 2024

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.

stubailo avatar stubailo commented on May 1, 2024

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.

stubailo avatar stubailo commented on May 1, 2024

Sorry by "this package" I mean the eslint plugin.

from graphql-tools.

lpil avatar lpil commented on May 1, 2024

Oh wonderful, thank you. :)

from graphql-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.