-
-
Notifications
You must be signed in to change notification settings - Fork 239
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
GraphQL integration #118
Comments
OK, I have some very basic implementation here. We have few problems to solve, in order to make it real:
|
https://github.com/kuip/meteor-schema-graphql-bridge could spark some ideas sorry I'm on my phone but I'm really excited about this and will post more Sent from my iPhone On Oct 25, 2016, at 21:48, "Radosław Miernik" notifications@github.com @MacRusher https://github.com/MacRusher @macrozone — |
There's also |
Here are my conclusions:
Example: const schema = new GraphQLBridge(`
type Author {
# Label
id: ID!
decimal: Float
firstName: Int
lastName: String
posts: [Post]
}
type Post {
id: Int!
title: String
author: Author
votes: Int
}
# This will be used as the form schema.
type Query {
posts: [Post]
}
`, model => {
if (!model.posts || model.posts.length === 0) {
// This is just example.
// Structure inspired by ValidationError.
throw {
details: [
{field: 'posts', message: 'At least one post is required.'}
]
};
}
// More validation...
}); Looks good, huh? Now, let's take a look at additional props. We can pass it to the schema, as a third parameter: const schema = new GraphQLBridge(graphQL, validator, {
posts: {
minCount: 1,
maxCount: 4
},
// Again - it's just an example.
// Notation inspired by SimpleSchema.
'posts.$.title': {
placeholder: 'Some creative title...'
}
}); What do you think? If you think, this will work (and it's enough), then we have it! My experimental bridge is almost it! But wait, there's more!If you don't like the idea of passing raw schema to the import {makeExecutableSchema} from 'graphql-tools';
const executableSchema = makeExecutableSchema({...});
// Any type can be passed to the form.
const schema = new GraphQLBridge(executableSchema.getType('Post'), ...); |
Wow, indeed I like the On Wed, Nov 2, 2016 at 9:23 PM, Radosław Miernik notifications@github.com
|
Every form is already abstracted from the schema. This logic is placed in |
Good news! GraphQL support just landed in |
Note: Created as a successor of this comment in #112.
More and more projects are using graphql, so some kind of integration would be nice. Some research about parsing graphql schemas would be nice (and I'll probably do it in some free time), but further customizations directly in schema might be an overkill.
Ideas? Thoughts?
The text was updated successfully, but these errors were encountered: