Skip to content
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

Spec and Build client-side GraphQL parser. #21

Closed
leebyron opened this issue Jul 4, 2015 · 6 comments
Closed

Spec and Build client-side GraphQL parser. #21

leebyron opened this issue Jul 4, 2015 · 6 comments

Comments

@leebyron
Copy link
Contributor

leebyron commented Jul 4, 2015

Client-side GraphQL should have access to the type IDL we refer to in the spec and any other features that are useful for client-side GraphQL development but have no semantic meaning for execution.

@ecstasy2
Copy link

ecstasy2 commented Jul 7, 2015

What would be a good way to start helping on this?

@leebyron
Copy link
Contributor Author

leebyron commented Jul 7, 2015

We're not sure yet. We'll speak with those working on GraphQL client tools at Facebook to figure out what will best support their needs and that will help us understand the direction to move in.

@charypar
Copy link

charypar commented Jul 8, 2015

More about #16 (I think?), but is there any vision for parsing the schema definition language into (partial) "AST" (which you now build by hand) and providing an API to define resolve functions for individual attributes?

I have something roughly like this in mind:

import {schemaDefine} from 'graphql'

const schema = schemaDefine(`
type User {
    name: String!
    interests: [String]
}

queryType {
    user(id: ID): User
}
`);

schema.getType('User').defineFieldResolvers(() => {
    name: (user) => user.name,
    interests: (user) => user.interests.map(interest => interest.label)
});

...

There's obviously more thinking to be done around defining custom scalars, etc., but is this something that you have on the roadmap or would be interested in?

@leebyron
Copy link
Contributor Author

This isn't something on the roadmap. We haven't considered an approach like that very seriously because while it could make simple cases more terse, it could also be harder to understand and harder to extend.

Documentation, for example, is missing from this particular suggestion and a critical part of a well built GraphQL server, so we want to avoid giving tools that makes documentation harder rather than easier.

There's probably something to a partial code-generation (similar to Rails or Yeoman) that would be really valuable to reduce typing, which is one of the interesting paths that could be taken for building a parser for client-side types.

The primary desire for client-side types, at least from how I've seen GraphQL used at Facebook over the last 3 years, is for doing code-generation in our client applications when the types a GraphQL server provides need to be extended by the iOS or Android client.

@leebyron
Copy link
Contributor Author

This is now mostly covered by #74

@leebyron
Copy link
Contributor Author

leebyron commented Apr 7, 2016

Individual changes increment towards this, and the tracking task is at graphql/graphql-spec#90

@leebyron leebyron closed this as completed Apr 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants