question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: schema.js => schema.graphql?

See original GitHub issue

My current setup has my schema in a .js file, like this:

const typeDefs = `

type InstantMessages {
  id: Int
  from_id: String
  to_id: String
  msgText: String
}
[.....]

schema {
  query: Query,
  mutation: Mutation
  subscription: Subscription
}
`;

export default typeDefs;

Then in order to use the schema with Apollo via swydo-ddp-apollo, I do this:

import AllResolvers from "./api/resolvers";
import AllSchema from "./api/schema";

//APOLLO
import {setup} from 'meteor/swydo:ddp-apollo';

const typeDefs = [AllSchema];
const resolvers = [AllResolvers];

const schema = makeExecutableSchema({
    typeDefs,
    resolvers
});

setup({
    schema
});

If I rename schema.js => schema.graphql, I can’t export the schema.

What is the correct way to solve this?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
VikR0001commented, Aug 20, 2020

@vepanimas Awesome. This is working. Thanks very much!

0reactions
vepanimascommented, Aug 20, 2020

@VikR0001 ok, I’m not familiar with meteor myself, but it looks like you should use this package. There is an example of exactly what you want to implement for a schema loading. After that, you will be able to import from any graphql file in your js files. Then you should move your schema from .js file to schema.graphql. And the last step is creating .graphqlconfig at the root of a project.

More details about creating a config could be found here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQL schema basics - Apollo GraphQL Docs
Your GraphQL server uses a schema to describe the shape of your available data. This schema defines a hierarchy of types with fields...
Read more >
Schemas and Types - GraphQL
Every GraphQL service defines a set of types which completely describe the set of possible data you can query on that service. Then,...
Read more >
How to Retrieve a GraphQL Schema | by Mr. Thank You
A GraphQL schema is a document describing how a specific GraphQL server is structured. A GraphQL schema is like a SQL database design....
Read more >
GraphQL Schemas, TypeDefs & Resolvers - Prisma
Before starting to build your server, GraphQL requires you to design a schema which in turn defines the API of your server. In...
Read more >
Executable Schemas – GraphQL Tools
The GraphQL-Tools package allows you to create a GraphQL.js GraphQLSchema instance from GraphQL schema language using the function ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found